0% found this document useful (0 votes)
20 views

Graph Output

The document describes how to represent a graph as a 2D array and perform common graph operations like finding the indegree and outdegree of nodes, checking for self-loops, and determining if there is a direct edge between two nodes. It outlines inserting the graph into a 2D array, then calculating indegree and outdegree for a given node, checking for any self-loops, and checking if there is a direct edge between two input nodes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Graph Output

The document describes how to represent a graph as a 2D array and perform common graph operations like finding the indegree and outdegree of nodes, checking for self-loops, and determining if there is a direct edge between two nodes. It outlines inserting the graph into a 2D array, then calculating indegree and outdegree for a given node, checking for any self-loops, and checking if there is a direct edge between two input nodes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

0 1

2 3

0 1 2 3

0 0 1 1 0

1 0 0 0 0

2 0 1 0 1

3 0 1 0 0

1. Insert the graph in a two dimensional array.

For(i=0; i<n; i++)

For(j=0; j<n; j++)

Scanf(“%d”,&gr[i][j])
2. Find the indegree and outdegree of a given node.
Input:
Node: 2
Output:
Indegree of 2 is 1 and outdegree of 2 is 2.
3. Find any self-loop in the graph.
4. Find whether there is a direct edge between two node:
Input:
Node 1: 2
Node 2: 3
Output:
Yes

You might also like