Class Graph

java.lang.Object
org.ddolib.examples.mcp.Graph

public class Graph extends Object
Represents a Graph with adjacency matrix. Used for MCP problem
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
     
    final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Graph(int[][] adjacencyMatrix)
    Given an adjacency matrix instantiate a graph.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
    weightOf(int from, int to)
    Given two nodes, returns the weight of their edges.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • numNodes

      public final int numNodes
    • numEdges

      public final int numEdges
  • Constructor Details

    • Graph

      public Graph(int[][] adjacencyMatrix)
      Given an adjacency matrix instantiate a graph. As these class is only used for MCP, we suppose that 2 nodes are not connected if the edge has weight 0
      Parameters:
      adjacencyMatrix - The adjacency matrix to initialize the graph.
  • Method Details

    • weightOf

      public int weightOf(int from, int to)
      Given two nodes, returns the weight of their edges.
      Parameters:
      from - The start node of the edge.
      to - The end node of the edges.
      Returns:
      The weight of the edge.
    • toString

      public String toString()
      Overrides:
      toString in class Object