Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
2ce645df
Commit
2ce645df
authored
Jul 20, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to get the edge ID given the from and to node.
parent
049fc7d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
Graph.py
Graph.py
+18
-4
No files found.
Graph.py
View file @
2ce645df
...
...
@@ -127,6 +127,21 @@ class DirectedGraph(object):
"""
return
p_id
in
self
.
_edge_numbers
def
edge_id
(
self
,
p_from
,
p_to
):
"""
Returns the edge ID given the from and to nodes.
Returns None if the edge does not exist or has no value assigned.
"""
result
=
None
for
key
,
value
in
self
.
_edge_numbers
.
iteritems
():
if
value
==
(
p_from
,
p_to
):
result
=
key
break
return
result
def
remove_edge
(
self
,
p_from
,
p_to
,
remove_unconnected_nodes
=
True
):
"""
Removes an edge from the graph.
...
...
@@ -137,10 +152,9 @@ class DirectedGraph(object):
if
self
.
has_edge
(
p_from
,
p_to
):
self
.
_edges
[
p_from
].
remove
(
p_to
)
for
key
,
value
in
self
.
_edge_numbers
.
iteritems
():
if
value
==
(
p_from
,
p_to
):
del
self
.
_edge_numbers
[
key
]
break
edge_id
=
self
.
edge_id
(
p_from
,
p_to
)
if
edge_id
:
del
self
.
_edge_numbers
[
edge_id
]
if
remove_unconnected_nodes
:
if
self
.
is_isolated
(
p_from
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment