473,383 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

adjacency matrix c++

Define a class for an adjacency matrix representation of weighted, directed graphs in C++.
2. Implement the following essential methods in your class. Any input validation or exceptions
must be handled within the methods.
• addNode - adds a new node (vertex) to the graph
• deleteNode(i) - deletes a given node, i from the graph
• addEdge(i,j,w) - adds an edge from node i to node j with weight w
• deleteEdge(i,j) - deletes the edge from node i to node j
• countNodes - returns the number of nodes in the graph
• countEdges - returns the number of edges in the graph
• displayGraph - displays the adjacency matrix for the graph
• displayShortestPathLengths - displays a matrix that contains the lengths of the shortest path
between all pairs of nodes in the graph
• displayShortestPath(i,j) - displays the sequence of nodes that form the shortest path from
node i to node j
3. Write a client (main program) to test your class. The client should display a menu to the user as
described below.
a) One of the options in the menu should be “Read Graph” which would allow the client to
read an adjacency matrix representation of a graph directly from a text file. The format of
the text file to be read is given below. Note: The first line in the text file has the number of
nodes (vertices) and the rest of the data is the adjacency matrix indicating the weights on
the edges between all pairs of nodes in the graph (-1 is used to represent “no edge”).
Oct 2 '07 #1
2 7630
weaknessforcats
9,208 Expert Mod 8TB
Is there a question here?
Oct 2 '07 #2
Read the policy about homeworks

To get started on this, remember that an adjacency matrix is a 2D array that contains a 1 (or a weight) if node[u][v] is an edge and a 0 if node[u][v] is not have an edge.
Oct 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: SallyBenjamin | last post by:
Hello.. Can anyone help me with this coding. Basically, it needs to have add node, remove node, add edges , remove edges and display the graph But.I have only succedded to add node, add and...
6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
0
by: Jef Driesen | last post by:
I need some help to implement the adjacency list representation of a (undirected) graph. The data structure I need is something like the picture on the website...
12
by: Steve | last post by:
I have been studying the Adjacency List Model as a means of achieving a folder structure in a project I am working on. Started with the excellent article by Gijs Van Tulder ...
0
by: amodagni | last post by:
Hi ! Could someone please guide me to SQL code required for managing data in tables in which hierarchical data stored in adjacency or Nested set model.
1
by: madhuparna | last post by:
Plzz give the code for implementing adjacency matrix in C
0
by: ZoeNet | last post by:
Hi all, The table structures are below. The table category_cat is built on the adjacency model (where the parent and child entries are both stored in the same table). For my problem, I've...
2
by: orzeech | last post by:
Here's my code that's supposed to be a basic graph implementation using adjacency lists. It comes straight from R.Sedgewick's "Algorithms in C++". However "23 - ISO C++ forbids declaration of...
0
by: kantai | last post by:
Need help in solving the problem below. Any help would be highly appreciated Implement the adt graph as a C++ class first by using an adjacency matrix to represent the graph then by using an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.