Subject Computer Science Java Programming


See Question.pdf

Note: the key part is how to convert this problem to the shortest path problem: 1) how to build the graph and how many graphs to build; 2) how to decide the source and destination; and 3) how to assign the weight on the edge.

Please write an unique program using basic Java and keep it simple.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.*;

public class Graph {
    static final int NUM_OF_VERT = 4; //this can be changed of course
    int matrix[][][]; //graph is represented by an adjacency matrix
    private Stack<Integer> Path = new Stack<>();   // the current path
    private ArrayList<Integer> InPath = new ArrayList<>();    // the set of vertices on the path
    private ArrayList<String> AllPaths = new ArrayList<>();    // list of all paths, one of them will be the correct path...

This is only a preview of the solution. Please use the purchase button to see the entire solution


or free if you
register a new account!

Related Homework Solutions

Get help from a qualified tutor
Live Chats