Note that there are some explanatory texts on larger screens.

plurals
  1. POGraph Representation using Linked-List
    primarykey
    data
    text
    <p>Im having some trouble trying to figure out how to get the pointers right when adding edges to a certain paired vertex.</p> <p>Below is a short idea about how the linked list should look like after Vertexs and Nodes are done being Inputed.</p> <p>How can i keep order on the neighborList as well? Should there be another condition if there is already a vertex edge in that current vertex?</p> <p>Heres the Structured Class im trying to build:</p> <pre><code>class graph{ private: typedef struct node{ char vertex; node * nodeListPtr; node * neighborPtr; }* nodePtr; nodePtr head; nodePtr curr; public: graph(); ~graph(); void AddNode(char AddData); void AddEdge(char V, char E); void printList(); }; graph::graph(){ head = NULL; curr = NULL; } // Adds a node to a linked list void graph::AddNode(char AddData){ nodePtr n = new node; n-&gt;nodeListPtr = NULL; n-&gt;vertex = AddData; if(head != NULL){ curr = head; while(curr-&gt;nodeListPtr != NULL){ curr = curr-&gt;nodeListPtr; } curr-&gt;nodeListPtr = n; } else{ head = n; } } // takes 2 Parameters (V is pointing to E) // I want to set it up where the neighborptr starts a double linked List basically void graph::AddEdge(char V, char E){ // New Node with data nodePtr n = new node; n-&gt;neighborPtr = NULL; n-&gt;vertex = E; // go to the first node in the nodeList and go through till you reach the Vertex V curr = head; while(curr-&gt;vertex != V){ curr = curr-&gt;nodeListPtr; } //Once the Vertex V is found in the linked list add the node to the neighborPtr. curr-&gt;neighborPtr = n; } </code></pre> <p><img src="https://i.stack.imgur.com/AKshm.png" alt="What Im trying to acheive in my Linked List Graph Rep."></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload