#13785: Export a graph to a dictionary
---------------------------------+------------------------------------------
Reporter: ncohen | Owner: jason, ncohen, rlm
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.6
Component: graph theory | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Nathann Cohen | Merged in:
Dependencies: #13784 | Stopgaps:
---------------------------------+------------------------------------------
Comment (by dcoudert):
In patch #13380, I need to modify a copy of the graph (including weights)
and then to compute a shortest path on the modified copy. So turning the
graph into a dictionary is not sufficient. Furthermore, since we not only
modify the weights, but also the graph topology (addition of reverse
arcs), a solution allowing to pass to the shortest path method a
dictionary of weights is not sufficient.
For triangle counts (#13503), we can replace
{{{
ggnx = self.networkx_graph()
for u in ggnx.nodes_iter():
tr += sum(ggnx.has_edge(v,w) for v,w in
combinations_iterator(ggnx.neighbors(u),2))
return tr/3
}}}
with
{{{
gg = self.to_dictionary()
for u in gg.iterkeys():
tr += sum(w in gg[v] for v,w in combinations_iterator(gg[u],2))
return tr/3
}}}
This will certainly be faster since we don't need edge labels or any other
decoration to count.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13785#comment:4>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.