From fbf2569a7eafe294cf6673ad2bec5fb47c6eafa1 Mon Sep 17 00:00:00 2001 From: Branislav Stojkovic Date: Fri, 8 Feb 2019 09:21:32 +0100 Subject: [PATCH] ground work for graph analysis --- .../diylc-core/src/org/diylc/graph/Graph.java | 25 +++++++ .../diylc-core/src/org/diylc/graph/Node.java | 65 +++++++++++++++++++ .../src/org/diylc/graph/Position.java | 65 +++++++++++++++++++ .../src/org/diylc/graph/Vertex.java | 54 +++++++++++++++ 4 files changed, 209 insertions(+) create mode 100644 diylc/diylc-core/src/org/diylc/graph/Graph.java create mode 100644 diylc/diylc-core/src/org/diylc/graph/Node.java create mode 100644 diylc/diylc-core/src/org/diylc/graph/Position.java create mode 100644 diylc/diylc-core/src/org/diylc/graph/Vertex.java diff --git a/diylc/diylc-core/src/org/diylc/graph/Graph.java b/diylc/diylc-core/src/org/diylc/graph/Graph.java new file mode 100644 index 00000000..d743567d --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/graph/Graph.java @@ -0,0 +1,25 @@ +package org.diylc.graph; + +import java.util.Dictionary; +import java.util.Set; + +public class Graph { + + private Dictionary positions; + private Set nodes; + + public Graph() { + } + + public Dictionary getPositions() { + return positions; + } + + public Set getNodes() { + return nodes; + } + + public boolean nodesMatch(Graph other) { + return this.nodes.equals(other.nodes); + } +} diff --git a/diylc/diylc-core/src/org/diylc/graph/Node.java b/diylc/diylc-core/src/org/diylc/graph/Node.java new file mode 100644 index 00000000..7a58ea57 --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/graph/Node.java @@ -0,0 +1,65 @@ +package org.diylc.graph; + + +public class Node { + + private String type; + private String component; + private String terminal; + + public Node() {} + + public String getType() { + return type; + } + + public String getComponent() { + return component; + } + + public String getTerminal() { + return terminal; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((component == null) ? 0 : component.hashCode()); + result = prime * result + ((terminal == null) ? 0 : terminal.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Node other = (Node) obj; + if (component == null) { + if (other.component != null) + return false; + } else if (!component.equals(other.component)) + return false; + if (terminal == null) { + if (other.terminal != null) + return false; + } else if (!terminal.equals(other.terminal)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } + + @Override + public String toString() { + return type + "." + component + "." + terminal; + } +} diff --git a/diylc/diylc-core/src/org/diylc/graph/Position.java b/diylc/diylc-core/src/org/diylc/graph/Position.java new file mode 100644 index 00000000..5102fac7 --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/graph/Position.java @@ -0,0 +1,65 @@ +package org.diylc.graph; + +public class Position { + + private String ownerType; + private String owner; + private String name; + + public Position() { + } + + public String getOwnerType() { + return ownerType; + } + + public String getOwner() { + return owner; + } + + public String getName() { + return name; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((owner == null) ? 0 : owner.hashCode()); + result = prime * result + ((ownerType == null) ? 0 : ownerType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Position other = (Position) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (owner == null) { + if (other.owner != null) + return false; + } else if (!owner.equals(other.owner)) + return false; + if (ownerType == null) { + if (other.ownerType != null) + return false; + } else if (!ownerType.equals(other.ownerType)) + return false; + return true; + } + + @Override + public String toString() { + return ownerType + "." + owner + "." + name; + } +} diff --git a/diylc/diylc-core/src/org/diylc/graph/Vertex.java b/diylc/diylc-core/src/org/diylc/graph/Vertex.java new file mode 100644 index 00000000..3b15ef1a --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/graph/Vertex.java @@ -0,0 +1,54 @@ +package org.diylc.graph; + +public class Vertex { + + private Node node1; + private Node node2; + + public Vertex() { + } + + public Node getNode1() { + return node1; + } + + public Node getNode2() { + return node2; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((node1 == null) ? 0 : node1.hashCode()); + result = prime * result + ((node2 == null) ? 0 : node2.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Vertex other = (Vertex) obj; + if (node1 == null) { + if (other.node1 != null) + return false; + } else if (!node1.equals(other.node1)) + return false; + if (node2 == null) { + if (other.node2 != null) + return false; + } else if (!node2.equals(other.node2)) + return false; + return true; + } + + @Override + public String toString() { + return node1.toString() + " -> " + node2.toString(); + } +}