Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Netbone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
coregraphie
Netbone
Merge requests
!1
Adding new methods and the consensual backbone
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Adding new methods and the consensual backbone
dev
into
main
Overview
0
Commits
18
Pipelines
0
Changes
1
Merged
Adding new methods and the consensual backbone
Ali Yassin
requested to merge
dev
into
main
Jul 3, 2023
Overview
0
Commits
18
Pipelines
0
Changes
1
Adding new methods and the consensual backbone
0
0
Merge request reports
Viewing commit
65bdf3b1
Prev
Next
Show latest version
1 file
+
2
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
65bdf3b1
Refactorings Code and Adding Node Filter
· 65bdf3b1
Yassin
authored
May 9, 2023
netbone/backbone.py
+
31
−
33
View file @ d8397287
Edit in single-file editor
Open in Web IDE
import
networkx
as
nx
import
pandas
as
pd
from
pandas
import
DataFrame
from
netbone.utils.utils
import
edge_properties
class
Backbone
:
def
__init__
(
self
,
graph
,
name
,
column
,
ascending
,
filters
):
def
__init__
(
self
,
graph
,
method_name
,
property_name
,
ascending
,
compatible_filters
,
filter_on
):
if
isinstance
(
graph
,
DataFrame
):
graph
=
nx
.
from_pandas_edgelist
(
graph
,
edge_attr
=
edge_properties
(
graph
))
self
.
graph
=
graph
self
.
name
=
name
self
.
column
=
column
self
.
method_name
=
method_
name
self
.
property_name
=
property_name
self
.
ascending
=
ascending
self
.
compatible_filters
=
filters
self
.
filters
=
compatible_filters
self
.
filter_on
=
filter_on
def
to_dataframe
(
self
):
if
self
.
filter_on
==
'
Edges
'
:
return
nx
.
to_pandas_edgelist
(
self
.
graph
)
else
:
node_attrs
=
{}
for
node
in
self
.
graph
.
nodes
():
node_attrs
[
node
]
=
self
.
graph
.
nodes
[
node
]
# Convert the dictionary to a Pandas DataFrame
return
pd
.
DataFrame
.
from_dict
(
node_attrs
,
orient
=
'
index
'
)
def
narrate
(
self
):
match
self
.
name
:
match
self
.
method_
name
:
case
"
Disparity Filter
"
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
"
Enhanced Configuration Model Filter
"
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
"
Marginal Likelihood Filter
"
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
"
Locally Adaptive Network Sparsification Filter
"
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
"
Noise Corrected Filter
"
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
High Salience Skeleton Filter
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
Modularity Filter
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
Ultrametric Distance Filter
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
Maximum Spanning Tree
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
Metric Distance Filter
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
H-Backbone Filter
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
Doubly Stochastic Filter
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
'
Global Threshold Filter
'
:
print
(
self
.
name
)
print
(
self
.
method_
name
)
case
_
:
print
(
"
Citation here
"
)
def
filters
(
self
):
return
self
.
compatible_filters
# match self.name:
# case "Disparity Filter" | 'Noise Corrected Filter' | "Enhanced Configuration Model Filter" | "Marginal Likelihood Filter" | 'Locally Adaptive Network Sparsification Filter' | 'Global Threshold Filter':
# return [fraction_filter, threshold_filter]
# case "H-Backbone Filter" | 'Metric Distance Filter' | 'Maximum Spanning Tree' | 'Ultrametric Distance Filter' | 'Modularity Filter':
# return [boolean_filter]
# case "Doubly Stochastic Filter" | "High Salience Skeleton Filter":
# return [boolean_filter, fraction_filter, threshold_filter]
# case _:
# print("Error " + self.name + " does not exist")
def
compatible_filters
(
self
):
return
self
.
filters
Loading