The easiest way to represent a weighted graph with N nodes is with an NxN array. However, with 65000 nodes, the memory required would almost certainly be a problem.
Here is another way to do it: Use a structure to represent each edge. The struct contains the weight, one node id, and a pointer to an edge struct. Also have an array of edge struct pointers, one for each of the 65000 nodes. For each edge, create and populate two structs and insert one containing node_id2 into the linked list for node_id1 and the other containing node_id1 into the linked list for node_id2. Then you can find all edges from your current location by traversing the linked list. This should take about 15 megabytes of memory, which most computers can handle easily. Don On Mar 24, 11:21 am, snehal jain <learner....@gmail.com> wrote: > You have to create a graph in most efficient way from relationship of > nodes read from txt file. > text file contains information like: > node_id weight node_id > node_id weight node_id > ….. > // which means two nodes are connected with some weight. (undirected) > There are around 600K such information for about 65000 nodes. > Aim is to create a a subgraph for a given node_id. i.e for that > node_id find ALL successor nodes with level mentioned i.e form a > subgraph for that node. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.