views:

329

answers:

2

Any function in that Graphviz which can do that? If not, any other free software that can do that?

A: 

Compute the complement yourself, then plot it.

Hamish Grubijan
not that I nvr thought of this, it is just that sometimes the complement is very difficult to compute, esp if u hv many nodes and edges in the original graph
yeeen
so the follow up qn is whether there is any software or online tools that can accomplish it
yeeen
Well, graphviz is a good one for plotting. How many nodes and vertices do you have? What is the input format?
Hamish Grubijan
I want an efficient sw, so u can assume quite a lot of vertices and edges in the complement graph. Input is to manually type in...
yeeen
+2  A: 

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")
doug
This looks like what I want. But how do i install networkx using the downloaded Python Egg file? The quick download in the install.txt only says "Get NetworkX from the Python Package Index at http://pypi.python.org/pypi/networkxor install it with:: easy_install networkx and an attempt will be made to find and install an appropriate versionthat matches your operating system and Python version." I have installed Python btw.
yeeen
You need to install 'setuptools' in order to be able to install packages via 'eggs.' I don't know your OS, so here's the link to a step-by-step guide: http://peak.telecommunity.com/DevCenter/EasyInstall. if you don't want to install using setuptools ('eggs'), go to the Networkx repository (http://networkx.lanl.gov/download/networkx/) dll and unpack the latest version appropriate for your OS, open a shell, cd into the package's top-level directory and type at the shell prompt: 'sudo python setup.py install' (without the quotes). That will install it.
doug