how to represent a list of edges since we have a graph with nodes and edges. do not talk about adjacency lists

advertisements

what is an edge list?not an adjacency list.. and how do we represent an edge list in C programming provided that we are given a graph with nodes and edges?


Here is the base structure

struct Edge
{
    int id;
    int weight; // If you need one
    vector<Edge *> neighbours; // List of references on your neightbours
}

vector<Edge> graph;

But as Michael noticed it does look like a homework :) Take a look at boot graphs library.

UPDATE C version

struct Edge
{
    int id;
    int weight; // If you need one
    Edge *next; // Next edge in the list
    Edge *neighbours; // List of neightbours
}

Edge *graph;