C++ Programming Code Examples C++ > Computer Graphics Code Examples Program to Describe the Representation of Graph using Incidence List Program to Describe the Representation of Graph using Incidence List - This algorithm represent a graph using incidence list. - The time complexity of this algorithm is O(e). - This algorithm takes the input of the number of vertex and edges. - Then it takes the input of connected vertex pairs. - Print the incidence list. - Exit. #include<iostream> using namespace std; int main() { int i, v, e, j, count; // take the input of the number of edges. cout<<"Enter the number of vertexes of the graph: "; cin>>v; cout<<"\nEnter the number of edges of the graph: "; cin>>e; int edge[e][2]; // Take the input of the adjacent vertex pairs of the given graph. for(i = 0; i < e; i++) { cout<<"\nEnter the vertex pair for edge "<<i+1; cout<<"\nV(1): "; cin>>edge[i][0]; cout<<"V(2): "; cin>>edge[i][1]; } // Print the incidence list representation of the graph. cout<<"\n\nThe incidence list representation for the given graph: "; for(i = 0; i < e; i++) { // For each vertex print, its adjacent vertex. cout<<"\n\tE("<<i+1<<") -> { "; cout<<"V("<<edge[i][0]<<") , "<<"V("<<edge[i][1]<<")"; cout<<" }"; } }