merge two nodes of adjacency list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kabhad
    New Member
    • Jan 2016
    • 1

    merge two nodes of adjacency list

    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];
    adjOutEddgeList s *outEddges;
    //adjInEddgeLists *inEddges;
    } AdjListNode;

    typedef struct adjOutEddgeList s{
    AdjListNode *listNode;
    adjOutEddgeList s *next;
    }adjOutEddgeLis ts;
Working...