Correctness of networkx line digraph construction -
the following python code:
import networkx nx g = nx.digraph() g.add_nodes_from([0, 1]) g.add_edges_from([(0,0), (0,1), (1,0), (1,1)]) nx.write_dot(g, 'g.dot') gl = nx.line_graph(g) nx.write_dot(gl, 'gl.dot')
creates following dot format graphs:
--- g.dot ---
digraph { 0 -> 0; 0 -> 1; 1 -> 0; 1 -> 1; }
--- gl.dot ---
strict digraph { "(0, 1)" -> "(1, 1)"; "(1, 0)" -> "(0, 0)"; "(0, 0)" -> "(0, 1)"; "(1, 1)" -> "(1, 0)"; }
should edges:
"(1, 0)" -> "(0, 1)"; "(0, 1)" -> "(1, 0)"; "(0, 0)" -> "(1, 1)"; "(1, 1)" -> "(0, 0)";
be in line graph construction?
nx.line_graph
creates strict digraph. strict means there no loops , no repeated edges. "(0, 1)" -> "(1, 0)"
loop, not included. in other words, "two vertices representing directed edges u v , w x in g connected edge uv wx in strict line digraph when v = w and u != x". (quote wikipedia - insertions bold).
Comments
Post a Comment