Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. private void FindEuler_H(Walk euler) {
  2. Euler G, G2;
  3. Walk C, C2;
  4. int randomVertex, circuitEdges;
  5. int[] matchingVertices;
  6. G = this; // For clarity
  7. C = new Walk(G.getTotalV());
  8. randomVertex = G.rand.nextInt(G.getTotalV);
  9. // Uses G2 instead of G for first C intialization because newCircuit alters Graph already
  10. G2 = (Euler)G.clone();
  11. circuitEdges += G2.newCircuit(firstVertex, G2.findConnectingVertex(firstVertex), C);
  12. C2 = (Walk)C.clone();
  13.  
  14. while (circuitEdges == G.getTotalE() ) {
  15. // New circuit already changes edges/verties of G
  16. if (!G2.noVerticesLeft()) {// Still vertices left in matrix
  17. // finds vertex
  18. matchingVertices = G2.verticesInCommon(circit);
  19. randomVertex = matchingVertices[G2.rand.nextInt(matchingVertices.length)]; // Value at matchingVertices repersents vertice
  20. C2.clear();
  21. circuitEdges += G2.newCircuit(randomVertex, G2.findConnectingVertex(randomVertex), C2);
  22. C.insertCircuit(C2);
  23. }
  24. }
  25. return C;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement