No Graph is Being Displayed in IGraph

Go To StackoverFlow.com

0

I have been trying to make graphs using the igraph library in c. I have even reinstalled it but i am unable to understand the problem. The whole program is compiled successfully but i get no graph as an output. All the printf's are executed and are shown in the output only the graph seems to be missing.

Please help i am stuck in this problem.

#include <igraph.h>

int main(void)
{
 igraph_real_t diameter;
 igraph_t graph;
 igraph_erdos_renyi_game(&graph, IGRAPH_ERDOS_RENYI_GNP, 1000, 5.0/1000,
                         IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS);
 igraph_diameter(&graph, &diameter, 0, 0, 0, IGRAPH_UNDIRECTED, 1);
 printf("Diameter of a random graph with average degree 5: %f\n",
         (double) diameter);
 igraph_destroy(&graph);
 return 0;
}

This is the code i am using. Only the printf statement is being printed.There is no error or warning.

2012-04-05 02:59
by Fyre
Is this your code or any of the example code in igraph? Do the examples work fine - Gangadhar 2012-04-05 03:02
yes it is an example from the igraph documentation - Fyre 2012-04-05 04:00
Is there any error displayed on the stdout / log file. Also, are you using the python interface or the C example to test this. Some more information regarding the OS, the example you are trying to execute will help - Gangadhar 2012-04-05 04:15
i have added the code above and i am running it on ubuntu. I have successfully installed the library using make and that is the reason the code is being compiled. But i am just not able to get any graph output only the printfs on the stdout - Fyre 2012-04-05 05:13
Not an expert in iGraph, but looks to me that you are not using the plot() function to actually display the graph. You have to show the graph for it to display. Example for Erdos-Rnyi is here - http://igraph.sourceforge.net/screenshots2.htm - Gangadhar 2012-04-05 11:10
can u tell me the exact syntax for c - Fyre 2012-04-05 11:18
Shooting in the dark here, did this code snippet work? http://igraph.sourceforge.net/doc/html/ch03s02.htm - Gangadhar 2012-04-05 14:50


0

You are using igraph from C, and the C core of igraph completely lacks plotting capabilities. (This is deliberate). If you want to plot graphs, you have to use igraph's Python or R bindings; in the Python and R modules, plotting is implemented on top of the C core library.

2012-04-05 17:56
by Tamás
Thank you tamas. But can this binding run for c codes. i mean i have some c codes from which i want to generate the graphs if possible please hel - Fyre 2012-04-05 18:03
please help i am stuck in this problem for a quite a long time.Can i generate graph using c code - Fyre 2012-04-05 20:52
Yes you can, but generating the graph is completely different from visualizing it. You can do the generation by using igraph directly from C, but you need to save the graph in some format and load it in a graph visualization software such as Graphviz, Gephi or Cytoscape if you want to visualize it - Tamás 2012-04-05 22:55
Is there any way to visualize the graph from python after getting it generated by the c code - Fyre 2012-04-05 23:28
Of course, but what's the point? You can just call the generating functions from Python as well. But if you insist on generating the graph from C and visualizing it from Python, then save your graph to a file from your C code, load it from the Python interface and then call the plot function on it - Tamás 2012-04-06 20:49
Yeah that is what i want to know can you give me a little example on how i could do this by saving the edge list from c in a text file i have tried to read in igraph but its not working. A little help will be of great use. Thank - Fyre 2012-04-06 23:42
Like when i use graph.data.frame to read from a file i get File "",line 1 g=graph.data.frame(as.data,frame(el) - Fyre 2012-04-06 23:46
Use igraph_write_graph_edgelist from C to save the edge list to a text file (see http://igraph.sourceforge.net/doc/html/igraphwritegraph_edgelist.html for more information). You can then read it back in Python using import igraph; g = igraph.load("edgelist.txt", format="edgelist"), or in R using library(igraph); g <- read.graph("edgelist.txt", format="edgelist") - Tamás 2012-04-07 19:08
Ads