/** Source code example for "A Practical Introduction to Data Structures and Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright 2008-2011 by Clifford A. Shaffer */ /** Graph: Adjacency matrix */ class Graphm implements Graph { private int[][] matrix; // The edge matrix private int numEdge; // Number of edges public int[] Mark; // The mark array public Graphm() {} // Constructors public Graphm(int n) { Init(n); } public void Init(int n) { Mark = new int[n]; matrix = new int[n][n]; numEdge = 0; } public int n() { return Mark.length; } // # of vertices public int e() { return numEdge; } // # of edges /** @return v's first neighbor */ public int first(int v) { for (int i=0; i