"delete and search edge in adjacency matrix of a 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 "delete and search edge in adjacency matrix of a graph" answered properly. Developers are finding an appropriate answer about delete and search edge in adjacency matrix of a graph related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like delete and search edge in adjacency matrix of a graph. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on delete and search edge in adjacency matrix of a graph.
delete and search edge in adjacency matrix of a graph
/*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 check(int mat[][v],int start,int endvertix)
{
if(mat[start][endvertix]==1)
{
cout<<"edge exists:"<<endl;
}
else
{
cout<<"edge does not exist:"<<endl;
}
}
void removeedge(int mat[][v],int start,int edgeend)
{
mat[start][edgeend]=0;
}
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);
cout<<"now above graph is not consider as we will remove edge '3->4' AND edge '1->3':"<<endl;
removeedge(array_in_graph,3,4);
removeedge(array_in_graph,1,3);
printmat(array_in_graph);
check(array_in_graph,1,4);
check(array_in_graph,3,4);
return 0;
}
All those coders who are working on the C++ based application and are stuck on delete and search edge in adjacency matrix of a graph can get a collection of related answers to their query. Programmers need to enter their query on delete and search edge in adjacency matrix of a graph related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about delete and search edge in adjacency matrix of a graph for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of delete and search edge in adjacency matrix of a graph while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "delete and search edge in adjacency matrix of a graph". Visit this developer's friendly online web community, CodeProZone, and get your queries like delete and search edge in adjacency matrix of a graph resolved professionally and stay updated to the latest C++ updates.