Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is java program i need help with, i ahve attached the program it needs. WeightGraph // Incomplete version //---------------------------------------------------------------------------- // WeightedGraph.java by Dale/Joyce/Weems Chapter
This is java program i need help with, i ahve attached the program it needs.
WeightGraph
// Incomplete version //---------------------------------------------------------------------------- // WeightedGraph.java by Dale/Joyce/Weems Chapter 9 // // Implements a directed graph with weighted edges. // Vertices are objects of class T and can be marked as having been visited. // Edge weights are integers. // Equivalence of vertices is determined by the vertices' equals method. // // General precondition: Except for the addVertex and hasVertex methods, // any vertex passed as an argument to a method is in this graph. //---------------------------------------------------------------------------- package graphs; import queues.*; public class WeightedGraphimplements WeightedGraphInterface { public static final int NULL_EDGE = 0; private static final int DEFCAP = 50; // default capacity private int numVertices; private int maxVertices; private T[] vertices; private int[][] edges; private boolean[] marks; // marks[i] is mark for vertices[i] public WeightedGraph() // Instantiates a graph with capacity DEFCAP vertices. { numVertices = 0; maxVertices = DEFCAP; vertices = (T[]) new Object[DEFCAP]; marks = new boolean[DEFCAP]; edges = new int[DEFCAP][DEFCAP]; } public WeightedGraph(int maxV) // Instantiates a graph with capacity maxV. { numVertices = 0; maxVertices = maxV; vertices = (T[]) new Object[maxV]; marks = new boolean[maxV]; edges = new int[maxV][maxV]; } public boolean isEmpty() // Returns true if this graph is empty; otherwise, returns false. { return (numVertices == 0); } public boolean isFull() // Returns true if this graph is full; otherwise, returns false. { return (numVertices == maxVertices); } public void addVertex(T vertex) // Preconditions: This graph is not full. // Vertex is not already in this graph. // Vertex is not null. // // Adds vertex to this graph. { vertices[numVertices] = vertex; for (int index = 0; index getToVertices(T vertex) // Returns a queue of the vertices that are adjacent from vertex. { UnboundedQueueInterface adjVertices = new LinkedUnbndQueue (); int fromIndex; int toIndex; fromIndex = indexIs(vertex); for (toIndex = 0; toIndex
Please also tell me which files i need to compile the whole program. thank you
eraph class with the vertices stored Design and code a reference-based weighted graph class with the vertices stored in a linked list as in Figure 9.11(b). Your class should implement our WeightedGraphlnterface, The WeightedGraph class is provided in the Extra Files folder via D2L Content. Implement and test an updated toString () method for the new WeightedGraphList class. Use the graph from the textbook on p. 637 Figure 9.9 EXTRA CREDIT +5 points: Implement an updated isPath2 algorithm for the following vertices in your driver program (this requires updating several other methods for the new WeightedGraphList class) isPath2(g, start, end);//starts is "Dallas" and ends is "Houston
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started