Pharaoh Slot Forum

pharaohslot.

You are not logged in.

#1 2020-09-13 14:21:53

EliGoldsmi
Member
From: Denmark, Vinderup
Registered: 2020-09-13
Posts: 1

Click to share on Facebook (Opens in new window)

Implementation of graph representation with an adjacency matrix

Filed under:.

— Leave a comment        March 8

2011                 The following program reads a set of edges that define an undirected graph and creates a representation of this graph with an adjacency matrix, giving a[i][j] and a[j][i] the value of 1 if there is an edge from i to j or from j to i in the graph, or the value of 0 if it does not exist.
Also, we assume that the number of vertices V is a constant known at compilation time.
Otherwise, there should be dynamic memory allocation for the array that represents the adjacency matrix.
You should know that the  implementation  of the algorithm does not take into account issues of data input validation or proper management of dynamic memory (e.g.
avoiding memory leaks) because it is only necessary to highlight the logic of the algorithm.
#include <iostream> #include <cstdlib>  using name space  std;  const int V = 100;  int main () {   bool adj[V][V] = { false };    int i;   for (i = 0; i < V; i++)     adj[i][i] = true;    int j;   while (cin >> i >> j)     adj[i][j] = adj[j][i] = true;    return EXIT_SUCCESS; }           Rate this:.
Share this:.
Click to share on Facebook (Opens in new window).

Click to share on LinkedIn (Opens in new window)
Click to share on Twitter (Opens in new window)
Click to print (Opens in new window)
Click to email this to a friend (Opens in new window)

Like this:.
Like   Loading.
Related.
Tags: adjacency matrix, , , edges, , undirected, .

Vertices    Comments RSS feed                    Leave a Reply Cancel reply

Enter  your comment  here.
Fill in your details below or click an icon to  log in :.
Email  (Address never made public)                 Name                 Website                                                            You are commenting using your  WordPress.com  account.
( Log Out /     )                                                             You are commenting using your Google account.
( Log Out /     )                                                             You are commenting using your Twitter account.
( Log Out /     )                                                             You are commenting using  your Facebook  account.
( Log Out /     )                             Cancel   Connecting to %s             Notify me of new comments via email.
Notify me of new posts via email.

« Implementation of string search algorithm
Implementation of graph representation with an adjacency list

».
(79).
(21).
(15).
(26).
(4).
(7).
(55).
(24).
(4).
(16).
(14).
(4).
(7).
(10).
(78).
(11).
(9).
(1).
March 2011      M  T  W  T  F  S  S           123456      78910111213      14151617181920      21222324252627      28293031           « Feb     May ».
(2).
(4).
(1).
(1).
(2).
(1).
(1).
(1).
(2).
(1).
(9).
(1).
(8).
(1).
(1).
(2).
(4).
(7).
(1).
(1).
(1).
(8).
(12).
(1).
(2).
(1).
(2).
(1).
(2).
(1).
(1).
(4).
(20).
(13).
(5).
(2).
(10).
(13).
(10).
(10).
(20).
287,006 hits.
Send to  Email Address           Your Name       Your Email Address                              Cancel       Post was not sent - check your email addresses.
Email check failed.

Please try again          Sorry

your blog cannot share posts by email.
%d  bloggers like this:.

Offline

Board footer

Powered by FluxBB