#19014: Tarjan Strongly Connected Components Algorithm
-------------------------------------+-------------------------------------
Reporter: borassi | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.9
Component: graph theory | Resolution:
Keywords: Strongly | Merged in:
connected components, Tarjan | Reviewers:
Authors: Michele Borassi | Work issues:
Report Upstream: N/A | Commit:
Branch: | 8df530ab5c761501b10ba397e361889b4be91833
u/borassi/tarjan_strongly_connected_components_algorithm| Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by borassi):
Hello!
I think that the method `is_strongly_connected` does not depend on this
patch, and what you are proposing is already implemented in routine
`is_strongly_connected` in `c_graph` (which also saves some time since it
does not copy the whole graph).
Indeed, this method is much simpler than computing SCCs: it performs a
forward and backward visit from any node, and sees if we reach all
vertices. Hence, I think it should be left as it is. For completeness, I
attach the code of this routine.
Soon I will correct all the issues you raised in comment 5!
See you,
Michele
{{{
def is_strongly_connected(self):
cdef int v_int = 0
cdef CGraph cg = self._cg
# Pick one vertex
v_int = bitset_first(cg.active_vertices)
if v_int == -1:
return True
v = self.vertex_label(v_int)
cdef int n = 0
for _ in self.depth_first_search(v):
n += 1
if cg.num_verts != n:
return False
n = 0
for _ in self.depth_first_search(v, reverse=True):
n += 1
return cg.num_verts == n
}}}
Replying to [comment:9 dcoudert]:
> Well, if you look at the code you will see that it is not so orthogonal:
if the backend has the method, we use it. Otherwise we count the number of
scc, and so we rely on this ticket.
> We need a backward BFS/DFS to get ride of this dependency.
--
Ticket URL: <http://trac.sagemath.org/ticket/19014#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.