igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Using basic querry commands for Igraph


From: ketan bhardwaj
Subject: Re: [igraph] Using basic querry commands for Igraph
Date: Fri, 22 May 2009 17:52:59 +0530

Hello Gabor,
 
here is what i do ... DO, EXPECT and NOTEXPECT are just checking macros that i have defined . Thanks for the help !
 
int main()
{
 igraph_t graph;
 int res;
 FILE * ipFile, *opFile;
 
 igraph_vector_t edges;
 igraph_integer_t nbVertex =0, nbEdges=0;
 
 
 start_program("**** STARTING PROGRAM ...****\n");
 
 
 DO("Open state_machine.txt and read_state_machine.txt...\n");
 ipFile = fopen("state_machine.txt","r+");
 NOT_EXPECT(ipFile,NULL);
 opFile = fopen("read_state_machine.txt","w+");
 NOT_EXPECT(ipFile,NULL);
 if(ipFile == NULL || opFile == NULL)
 goto END; 

 /* create and write the read graph from and to file*/
 DO("Creating Graph from file state_machine.txt...\n");
 res = igraph_read_graph_edgelist(&graph,ipFile,5,IGRAPH_DIRECTED);
 EXPECT(res,IGRAPH_SUCCESS);

 DO("Writing the read graph to read_state_machine.txt...\n"); 
 res = igraph_write_graph_edgelist(&graph,opFile);
 EXPECT(res,IGRAPH_SUCCESS);

 DO("Getting No. of vertices ...\n");
 nbVertex = igraph_vcount(&graph);
 printf("No. of vertex = %d \n",nbVertex);
 EXPECT(nbVertex,5);
 
 DO("Getting No. of Edges ...\n");
 nbEdges = igraph_ecount(&graph);
 printf("No. of edges = %d\n",nbEdges);
 EXPECT(nbEdges,12);

 DO("Destroying the graph...\n");
 res = igraph_destroy(&graph);
 EXPECT(res,IGRAPH_SUCCESS);
 //close open files
 DO("Closing Files ... \n");
 if(ipFile != NULL)
 fclose(ipFile);
 if(opFile !=NULL)
 fclose(opFile);


 DO("----------Done---------------\n");
END:
 return 1; 
}

On Fri, May 22, 2009 at 5:48 PM, Gábor Csárdi <address@hidden> wrote:
Ketan, this is hard to answer if you don't show us what you did exactly.

Best,
Gabor

On Fri, May 22, 2009 at 1:51 PM, ketan bhardwaj <address@hidden> wrote:
> Hello all,
>
> This is what i am doing :
> Create a graph using
> igraph_read_graph_edgelist()
>
> and counting the number of edges using igraph_ecount() but getting zero.
>
> here are the contents of file i am using
> 0 1 0 2 0 3 0 4 0 5 1 2 2 1 2 3 3 2 2 4 4 2 3 4 4 3
>
> Here are the contents of the file which i get from
> igraph_write_graph_edgelist()
>
> 0 1
>
> 0 2
>
> 0 3
>
> 0 4
>
> 0 5
>
> 1 2
>
> 2 1
>
> 2 3
>
> 2 4
>
> 3 2
>
> 3 4
>
> 4 2
>
> 4 3
> i think this is exactly right but why am i not be able to get the number of
> vertices.? any help.
>
> regards
> ketan
> --
> To get a comprehensive view of my work Please visit
> http://ketanbj.googlepages.com
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



--
Gabor Csardi <address@hidden>     UNIL DGM


_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help



--
To get a comprehensive view of my work Please visit http://ketanbj.googlepages.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]