Purchase Solution

Primitive functions on graph represented by adjacency matrix

Not what you're looking for?

Ask Custom Question

Modify the program that implements a 6x6 adjacency matrix for a graph. Remember that an adjacency matrix is a two-dimensional array.

The program should implement the necessary primitive functions on graphs:
updateNode(), insertNode(), insertEdge(), deleteNode(), deleteEdge(), retrieve(), and adjacent().

The program should also include a printGraph() method that prints the adjacency matrix.

The output of the program should appear as follows:

Adjacency Matrix:
0 1 2 3 4 5
0 0 1 1 1 0 0
1 0 0 0 0 1 0
2 0 1 0 0 1 0
3 0 0 0 0 0 0
4 0 0 0 0 0 0
5 0 1 0 1 0 0

The data are:
0: 0
1: 1
2: 2
3: 3
4: 4
5: 5
0 is connected to 1
3 is not connected to 2
** Press any key to continue **

Purchase this Solution

Solution Summary

Code has been inserted (but commented) to deal with undirected graphs as well.

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.