"adjacency matrix of a directed graph" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "adjacency matrix of a directed graph" answered properly. Developers are finding an appropriate answer about adjacency matrix of a directed graph related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like adjacency matrix of a directed graph. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on adjacency matrix of a directed graph. 

adjacency matrix of a directed graph

By ujjwal sotraujjwal sotra on May 21, 2021
/*adjacency matrix implementation of directed graph:
 0---->1---|
 |         |---->4
 |-> 2-->3-|
 
 -------------------------------------------------*/
#include <iostream>

using namespace std;
#define v 5
void inti(int mat[][v])
{
    for(int i=0;i<v;i++)
    {
        for(int j=0;j<v;j++)
        {
            mat[i][j]=0;
        }
    }
}
void addedge(int mat[][v],int start,int endvertix)
{
    mat[start][endvertix]=1;
}
void printmat(int mat[][v])
{
    for(int i=0;i<v;i++)
    {
        for(int j=0;j<v;j++)
        {
            cout<<mat[i][j]<<" ";
        }
        cout<<endl;

    }
}

int main()
{
    int array_in_graph[v][v];
    inti(array_in_graph);
    addedge(array_in_graph,0,1);
    addedge(array_in_graph,0,2);
    addedge(array_in_graph,0,3);
    addedge(array_in_graph,1,3);
    addedge(array_in_graph,1,4);
    addedge(array_in_graph,2,3);
    addedge(array_in_graph,3,4);
    printmat(array_in_graph);
    return 0;
}

Add Comment

0

All those coders who are working on the C++ based application and are stuck on adjacency matrix of a directed graph can get a collection of related answers to their query. Programmers need to enter their query on adjacency matrix of a directed graph related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about adjacency matrix of a directed graph for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of adjacency matrix of a directed graph while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "adjacency matrix of a directed graph". Visit this developer's friendly online web community, CodeProZone, and get your queries like adjacency matrix of a directed graph resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "adjacency matrix of a directed graph"

View All C++ queries

C++ queries related to "adjacency matrix of a directed graph"

Browse Other Code Languages

CodeProZone