开发者

How to draw complement of a network graph?

Any function in that Graphviz which can do that? If not, any other free开发者_如何学JAVA software that can do that?


Given that you want to render your graphs in graphviz, i suggest using the python library, networkx, to calculate graph complement. Networkx is an excellent library for graph theoretic analysis; it also has a seamless interface with graphviz.

(Rough definition of a graph complement: imagine a graph A', which has the identical nodes as A but that has all possible edges, i.e., every node is connected to every other node; now remove from A' the edges in A; what's left is the complement of A, A')

import networkx as NX
G = NX.gnm_random_graph(10, 10)   # create a random graph w/ 10 nodes, 10 edges
G_cmpl = NX.complement(G)         # get the complement of graph 'G'

# to render it in graphviz:
NX.write_dot(G_cmpl, "somefilename.dot")


Compute the complement yourself, then plot it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜