summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-08-03 15:28:17 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-08-03 15:28:17 +0200
commit90bb7e959496c3a12bebe055f6344b9f06f22809 (patch)
tree6635decc697d91c8cba6da9db8959b706ad9842f /cfg-to-paths/src/Path.java
parentc5a23ef9d6ab1e89b85016831fc8b2431f68f87f (diff)
Improving clarity through better Makefiles.
Diffstat (limited to 'cfg-to-paths/src/Path.java')
-rw-r--r--cfg-to-paths/src/Path.java102
1 files changed, 0 insertions, 102 deletions
diff --git a/cfg-to-paths/src/Path.java b/cfg-to-paths/src/Path.java
deleted file mode 100644
index 9e0897f..0000000
--- a/cfg-to-paths/src/Path.java
+++ /dev/null
@@ -1,102 +0,0 @@
-import java.util.*;
-
-public class Path
-{
- private final ArrayList<Node> nodes;
- private final Node last_node;
-
- public static Collection<Path> get_all_paths_from (final String root)
- {
- final Collection<Path> result;
- final Stack<Path> waiting_list;
- final Node root_node;
-
- root_node = Node.get_node(root);
-
- if (root_node == null)
- {
- System.err.println
- (
- "[E] Could not find root node \""
- + root
- + "\"."
- );
-
- return null;
- }
-
- result = new ArrayList<Path>();
- waiting_list = new Stack<Path>();
-
- waiting_list.push((new Path(Node.get_node(root))));
-
- while (!waiting_list.empty())
- {
- final Path current_path;
- final Node current_node;
- final Collection<Node> next_nodes;
-
- current_path = waiting_list.pop();
- current_node = current_path.last_node;
- next_nodes = current_node.next_nodes();
-
- if (next_nodes.isEmpty())
- {
- result.add(current_path);
- }
- else
- {
- if (current_node.is_terminal())
- {
- result.add(current_path);
- }
- for (final Node next: next_nodes)
- {
- waiting_list.push(current_path.add_step(next));
- }
- }
- }
-
- return result;
- }
-
- private Path (final Node start)
- {
- nodes = new ArrayList<Node>();
-
- nodes.add(start);
-
- last_node = start;
- }
-
- private Path (final ArrayList<Node> nodes, final Node last_node)
- {
- this.nodes = nodes;
- this.last_node = last_node;
-
- this.nodes.add(last_node);
- }
-
- @SuppressWarnings("unchecked")
- /* 'nodes' is an ArrayList<Node>, and so should be its clone. */
- private Path add_step (final Node n)
- {
- return new Path((ArrayList<Node>) nodes.clone(), n);
- }
-
- public Collection<List<Node>> get_all_subpaths ()
- {
- final Collection<List<Node>> result;
- final int path_length;
-
- result = new ArrayList<List<Node>>();
- path_length = nodes.size();
-
- for (int i = 0; i < path_length; ++i)
- {
- result.add(nodes.subList(i, path_length));
- }
-
- return result;
- }
-}