package hamierton;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Random;
public class EularCircuit {
public EularCircuit() {
}
public static void main(String[] args) {
// System.out.println("please input n:");
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = 4;
try {
// n = Integer.parseInt(br.readLine());
} catch (Exception ex) {
return;
}
try {
Graph g = new Graph(n);
g.printg();
g.circuit();
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
return;
}
}
}
class Node {
private static int count = 0;
private String name;
private ArrayList adjacencyList;
private boolean visited =false;
public Node() {
name = "node " + count;
adjacencyList = new ArrayList();
}
public Node(String name) {
this.name = name;
adjacencyList = new ArrayList();
}
public boolean isAllVisited() {
for (int i = 0; i < adjacencyList.size(); i++) {
SNode sn = (SNode) adjacencyList.get(i);
if (sn.visited == false) {
return false;
}
}
return true;
}
public boolean isvisited(){
return visited;
}
public void setvisited(){
visited = true;
}
public int getAdjacencyCount() {
return adjacencyList.size();
}
public boolean contains(int i) {
return this.adjacencyList.contains(new SNode(i));
}
public void removeAdjacencyNode(int i) {
this.adjacencyList.remove(new SNode(i));
}
public void addAdjacencyNode(int i) {
this.adjacencyList.add(new SNode(i));
}
public SNode getAdjacencyNode(int i) {
return (SNode) this.adjacencyList.get(i);
}
public SNode getAdjacencyNodeEX(int i_ref) {
for (int i = 0; i < this.getAdjacencyCount(); i++) {
if (getAdjacencyNode(i).index == i_ref) {
return getAdjacencyNode(i);
}
}
return null;
}
public String toString() {
return this.name;
}
}
class SNode {
public boolean visited = false;
public int index = 0;
2019-12-21 19:48:49
7KB
欧拉
1