Untitled

mail@pastecode.io avatar
unknown
java
a year ago
1.3 kB
2
Indexable
Never
package LAB9;

public class Main 
{
    public static void main(String[] args)
    {
        Graph graph = new Graph();

        // Create nodes
        GraphNode a = new GraphNode('a');
        GraphNode b = new GraphNode('b');
        GraphNode c = new GraphNode('c');
        GraphNode d = new GraphNode('d');
        GraphNode e = new GraphNode('e');
        GraphNode f = new GraphNode('f');
        GraphNode g = new GraphNode('g');
        GraphNode h = new GraphNode('h');
        GraphNode i = new GraphNode('i');

        // Add nodes to the graph
        graph.addNode(a);
        graph.addNode(b);
        graph.addNode(c);
        graph.addNode(d);
        graph.addNode(e);
        graph.addNode(f);
        graph.addNode(g);
        graph.addNode(h);
        graph.addNode(i);

        // Add edges between nodes with weights
        graph.addEdge(h, d, 1);
        graph.addEdge(a, i, 2);
        graph.addEdge(f, g, 2);
        graph.addEdge(e, c, 3);
        graph.addEdge(c, d, 4);
        graph.addEdge(a, f, 4);
        graph.addEdge(g, d, 5);
        graph.addEdge(a, b, 6);
        graph.addEdge(b, c, 7);
        graph.addEdge(e, g, 8);
        graph.addEdge(b, e, 9);

        // Print the graph
        graph.printGraph();
    }
}