Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Netbone
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
coregraphie
Netbone
Commits
89c62155
Commit
89c62155
authored
2 years ago
by
Yassin
Browse files
Options
Downloads
Patches
Plain Diff
Refactorings Code and Adding Node Filter
parent
f16596a5
No related branches found
No related tags found
1 merge request
!1
Adding new methods and the consensual backbone
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
netbone/filters.py
+19
-10
19 additions, 10 deletions
netbone/filters.py
with
19 additions
and
10 deletions
netbone/filters.py
+
19
−
10
View file @
89c62155
...
...
@@ -12,7 +12,7 @@ def boolean_filter(backbone, narrate=True, value=[]):
data
=
nx
.
to_pandas_edgelist
(
data
)
if
narrate
:
backbone
.
narrate
()
return
nx
.
from_pandas_edgelist
(
data
[
data
[
column
]
==
True
],
edge_attr
=
edge_properties
(
data
))
return
nx
.
from_pandas_edgelist
(
data
[
data
[
column
]],
edge_attr
=
edge_properties
(
data
))
print
(
"
The accepted filters for
"
+
backbone
.
method_name
+
"
are:
"
+
'
,
'
.
join
(
[
fun
.
__name__
for
fun
in
backbone
.
compatible_filters
()]))
...
...
@@ -21,19 +21,30 @@ def threshold_filter(backbone, value, narrate=True, secondary_property='weight',
**
kwargs
):
data
=
backbone
.
to_dataframe
()
property_name
=
backbone
.
property_name
ascending
=
backbone
.
ascending
filter_by
=
[
property_name
]
ascending
=
[
backbone
.
ascending
]
if
backbone
.
filter_on
==
'
Edges
'
:
filter_by
.
append
(
secondary_property
)
ascending
.
append
(
secondary_property_ascending
)
if
threshold_filter
in
backbone
.
compatible_filters
():
data
=
data
.
sort_values
(
by
=
[
property_name
,
secondary_property
]
,
ascending
=
[
ascending
,
secondary_property_ascending
]
)
data
=
data
.
sort_values
(
by
=
filter_by
,
ascending
=
ascending
)
if
narrate
:
backbone
.
narrate
()
if
ascending
:
return
nx
.
from_pandas_edgelist
(
data
[
data
[
property_name
]
<
value
],
edge_attr
=
edge_properties
(
data
))
if
backbone
.
ascending
:
data
=
data
[
data
[
property_name
]
<
value
]
if
backbone
.
filter_on
==
'
Edges
'
:
return
nx
.
from_pandas_edgelist
(
data
,
edge_attr
=
edge_properties
(
data
))
return
backbone
.
graph
.
subgraph
(
list
(
data
.
index
)).
copy
()
else
:
return
nx
.
from_pandas_edgelist
(
data
[
data
[
property_name
]
>
value
],
edge_attr
=
edge_properties
(
data
))
data
=
data
[
data
[
property_name
]
>
value
]
if
backbone
.
filter_on
==
'
Edges
'
:
return
nx
.
from_pandas_edgelist
(
data
,
edge_attr
=
edge_properties
(
data
))
return
backbone
.
graph
.
subgraph
(
list
(
data
.
index
)).
copy
()
print
(
"
The accepted filters for
"
+
backbone
.
method_name
+
"
are:
"
+
'
,
'
.
join
(
[
fun
.
__name__
for
fun
in
backbone
.
compatible_filters
()]))
...
...
@@ -45,7 +56,6 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight',
filter_by
=
[
backbone
.
property_name
]
ascending
=
[
backbone
.
ascending
]
if
backbone
.
filter_on
==
'
Edges
'
:
filter_by
.
append
(
secondary_property
)
ascending
.
append
(
secondary_property_ascending
)
...
...
@@ -60,9 +70,8 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight',
value
=
math
.
ceil
(
value
*
len
(
data
))
return
nx
.
from_pandas_edgelist
(
data
[:
value
],
edge_attr
=
edge_properties
(
data
))
else
:
b
=
backbone
.
graph
.
copy
()
value
=
math
.
ceil
(
value
*
len
(
backbone
.
graph
))
return
b
.
subgraph
(
list
(
data
[:
value
].
index
))
return
b
ackbone
.
graph
.
subgraph
(
list
(
data
[:
value
].
index
))
.
copy
()
print
(
"
The accepted filters for
"
+
backbone
.
method_name
+
"
are:
"
+
'
,
'
.
join
(
[
fun
.
__name__
for
fun
in
backbone
.
compatible_filters
()]))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment