Explore BrainMass
Share

Explore BrainMass

    Primitive functions on graph represented by adjacency matrix

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    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 **

    © BrainMass Inc. brainmass.com October 10, 2019, 1:15 am ad1c9bdddf
    https://brainmass.com/computer-science/arrays/primitive-functions-graph-represented-adjacency-matrix-327090

    Attachments

    Solution Summary

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

    $2.19