Package progs.lib

Examples of progs.lib.Graph


    String[] array = new String[]{
        "   ",
        "   ",
        "   ",
    };
    Graph graph = Graph.fromStringArray(array);
    Graph graph2 = Graph.fromStringArray(array);
    Assert.assertEquals(graph.getEdgeList(), graph2.getEdgeList());
  }
View Full Code Here


    String[] array = new String[]{
        "   ",
        "   ",
        "   ",
    };
    Graph graph = Graph.fromStringArray(array);
    Assert.assertEquals(2, new BFS(graph).distanceFrom(new Node(0, 0), new Node(2, 2)));
    Assert.assertEquals(2, new BFS(graph).distanceFrom(new Node(0, 0), new Node(0, 2)));
    array = new String[]{
        " ",
        "#",
View Full Code Here

    Assert.assertEquals(new Node(1, 1), solution.solveFor(room));
  }

  static class Solution {
    public Node solveFor(String[] room) {
      Graph graph = Graph.fromStringArray(room);
      List<Node> specialNodes = graph.getSpecialNodes();
      Set<Node> nodes = graph.getAllNodes();
      BFS bfs = new BFS(graph);
      int previousMinDistance = Integer.MAX_VALUE;
      Node bestNodeSoFar = null;
      for (Node node : nodes) {
        if (specialNodes.contains(node)) {
View Full Code Here

TOP

Related Classes of progs.lib.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.