By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,101 Members | 1,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,101 IT Pros & Developers. It's quick & easy.

merge two nodes of adjacency list

P: 1
how can i merge 2 nodes in a graph in 1 node , need to save the in and out edges and the nodes that was merged for contribution after that

for example a graph implementation in adj list:
1->3->4->6
2->3->4->6
5->4->6

and i want to merge the nodes 3 and 4 , then new nodes should be created 7 as :
1->7->6
2->7->6
5->7->6
7->6

the node 7 also will save [include 3,4 the merged nodes]
any one can help with that please

the implementation should be in c code.


typedef struct AdjListEntry {
int visited;
int index;
struct AdjListNode current; // node iniformation
struct AdjListEntry* next;
} AdjListEntry;

typedef struct AdjListNode {
int Uind;
char name[10];
char label[10];
adjOutEddgeLists *outEddges;
//adjInEddgeLists *inEddges;
} AdjListNode;

typedef struct adjOutEddgeLists{
AdjListNode *listNode;
adjOutEddgeLists *next;
}adjOutEddgeLists;
Feb 1 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.