diff --git a/.classpath b/.classpath
index 33a1f812..0a12aa03 100644
--- a/.classpath
+++ b/.classpath
@@ -10,5 +10,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/graph/graphfactory.properties b/config/graph/graphfactory.properties
new file mode 100644
index 00000000..75f8e1d8
--- /dev/null
+++ b/config/graph/graphfactory.properties
@@ -0,0 +1,34 @@
+######################################################################
+## SETTINGS FOR THE GRAPHFACTORY
+######################################################################
+
+## GF_GRAPHTYPE ######################################################
+# Possible Values:
+# * BITSY_DURABLE
+# * BITSY_NON_DURABLE
+# * DNA
+# * NEO4J2
+# * ORIENTDBNOTX
+# * TINKERGRAPH
+GF_GRAPHTYPE = TINKERGRAPH
+
+## GF_GDB_CLEAR_WORKSPACE_ON_CLOSE ###################################
+# Applies only for:
+# * BITSY_DURABLE
+# * NEO4J2
+GF_GDB_CLEAR_WORKSPACE_ON_CLOSE = true
+GF_GDB_WORKSPACE = data/GDB/
+
+## GF_GDB_OPERATIONS_PER_COMMIT [0 - INTEGER.MAX_VALUE]###############
+# Defines after how many operations a commit will be executed.
+# Default: 0
+# <0 : NO_COMMIT
+# =0 : COMMIT_ON_CLOSE
+# Example:
+# OPERATIONS_PER_COMMIT=1000 -> commit after 1000 operations
+GF_GDB_OPERATIONS_PER_COMMIT=0
+
+## GF_GDB_STORE_DNA_ELEMENTS_IN_GDB ##################################
+# If this option is true DNA tries to store the DNA elements (nodes,
+# edges) in the graph database if possible
+GF_GDB_STORE_DNA_ELEMENTS_IN_GDB=false
\ No newline at end of file
diff --git a/lib/GDB/bitsy/bitsy-1.5.1.jar b/lib/GDB/bitsy/bitsy-1.5.1.jar
new file mode 100644
index 00000000..704d5ecd
Binary files /dev/null and b/lib/GDB/bitsy/bitsy-1.5.1.jar differ
diff --git a/lib/GDB/bitsy/ness-core-1.5.0.jar b/lib/GDB/bitsy/ness-core-1.5.0.jar
new file mode 100644
index 00000000..0a52dac8
Binary files /dev/null and b/lib/GDB/bitsy/ness-core-1.5.0.jar differ
diff --git a/lib/GDB/blueprints/blueprints-core-2.6.0.jar b/lib/GDB/blueprints/blueprints-core-2.6.0.jar
new file mode 100644
index 00000000..4418549e
Binary files /dev/null and b/lib/GDB/blueprints/blueprints-core-2.6.0.jar differ
diff --git a/lib/GDB/blueprints/commons-beanutils-1.7.0.jar b/lib/GDB/blueprints/commons-beanutils-1.7.0.jar
new file mode 100644
index 00000000..b1b89c9c
Binary files /dev/null and b/lib/GDB/blueprints/commons-beanutils-1.7.0.jar differ
diff --git a/lib/GDB/blueprints/commons-beanutils-core-1.8.0.jar b/lib/GDB/blueprints/commons-beanutils-core-1.8.0.jar
new file mode 100644
index 00000000..87c15f45
Binary files /dev/null and b/lib/GDB/blueprints/commons-beanutils-core-1.8.0.jar differ
diff --git a/lib/GDB/blueprints/commons-collections-3.2.1.jar b/lib/GDB/blueprints/commons-collections-3.2.1.jar
new file mode 100644
index 00000000..c35fa1fe
Binary files /dev/null and b/lib/GDB/blueprints/commons-collections-3.2.1.jar differ
diff --git a/lib/GDB/blueprints/commons-configuration-1.6.jar b/lib/GDB/blueprints/commons-configuration-1.6.jar
new file mode 100644
index 00000000..2d4689a1
Binary files /dev/null and b/lib/GDB/blueprints/commons-configuration-1.6.jar differ
diff --git a/lib/GDB/blueprints/commons-digester-1.8.jar b/lib/GDB/blueprints/commons-digester-1.8.jar
new file mode 100644
index 00000000..1110f0aa
Binary files /dev/null and b/lib/GDB/blueprints/commons-digester-1.8.jar differ
diff --git a/lib/GDB/blueprints/commons-lang-2.4.jar b/lib/GDB/blueprints/commons-lang-2.4.jar
new file mode 100644
index 00000000..532939ec
Binary files /dev/null and b/lib/GDB/blueprints/commons-lang-2.4.jar differ
diff --git a/lib/GDB/blueprints/commons-logging-1.1.1.jar b/lib/GDB/blueprints/commons-logging-1.1.1.jar
new file mode 100644
index 00000000..1deef144
Binary files /dev/null and b/lib/GDB/blueprints/commons-logging-1.1.1.jar differ
diff --git a/lib/GDB/blueprints/concurrentlinkedhashmap-lru-1.4.1.jar b/lib/GDB/blueprints/concurrentlinkedhashmap-lru-1.4.1.jar
new file mode 100644
index 00000000..d4fbfe67
Binary files /dev/null and b/lib/GDB/blueprints/concurrentlinkedhashmap-lru-1.4.1.jar differ
diff --git a/lib/GDB/blueprints/hppc-0.6.0.jar b/lib/GDB/blueprints/hppc-0.6.0.jar
new file mode 100644
index 00000000..2fa17dd5
Binary files /dev/null and b/lib/GDB/blueprints/hppc-0.6.0.jar differ
diff --git a/lib/GDB/blueprints/jackson-annotations-2.2.3.jar b/lib/GDB/blueprints/jackson-annotations-2.2.3.jar
new file mode 100644
index 00000000..b62c87d7
Binary files /dev/null and b/lib/GDB/blueprints/jackson-annotations-2.2.3.jar differ
diff --git a/lib/GDB/blueprints/jackson-core-2.2.3.jar b/lib/GDB/blueprints/jackson-core-2.2.3.jar
new file mode 100644
index 00000000..24318a46
Binary files /dev/null and b/lib/GDB/blueprints/jackson-core-2.2.3.jar differ
diff --git a/lib/GDB/blueprints/jackson-databind-2.2.3.jar b/lib/GDB/blueprints/jackson-databind-2.2.3.jar
new file mode 100644
index 00000000..85450847
Binary files /dev/null and b/lib/GDB/blueprints/jackson-databind-2.2.3.jar differ
diff --git a/lib/GDB/blueprints/jettison-1.3.3.jar b/lib/GDB/blueprints/jettison-1.3.3.jar
new file mode 100644
index 00000000..332a475c
Binary files /dev/null and b/lib/GDB/blueprints/jettison-1.3.3.jar differ
diff --git a/lib/GDB/blueprints/slf4j-api-1.7.3.jar b/lib/GDB/blueprints/slf4j-api-1.7.3.jar
new file mode 100644
index 00000000..6bb83be8
Binary files /dev/null and b/lib/GDB/blueprints/slf4j-api-1.7.3.jar differ
diff --git a/lib/GDB/blueprints/slf4j-nop-1.7.3.jar b/lib/GDB/blueprints/slf4j-nop-1.7.3.jar
new file mode 100644
index 00000000..7689aabf
Binary files /dev/null and b/lib/GDB/blueprints/slf4j-nop-1.7.3.jar differ
diff --git a/lib/GDB/blueprints/stax-api-1.0.1.jar b/lib/GDB/blueprints/stax-api-1.0.1.jar
new file mode 100644
index 00000000..d9a16651
Binary files /dev/null and b/lib/GDB/blueprints/stax-api-1.0.1.jar differ
diff --git a/lib/GDB/neo4j/blueprints-neo4j2-graph-2.6.0.jar b/lib/GDB/neo4j/blueprints-neo4j2-graph-2.6.0.jar
new file mode 100644
index 00000000..3b3362a2
Binary files /dev/null and b/lib/GDB/neo4j/blueprints-neo4j2-graph-2.6.0.jar differ
diff --git a/lib/GDB/neo4j/geronimo-jta_1.1_spec-1.1.1.jar b/lib/GDB/neo4j/geronimo-jta_1.1_spec-1.1.1.jar
new file mode 100644
index 00000000..ee9963df
Binary files /dev/null and b/lib/GDB/neo4j/geronimo-jta_1.1_spec-1.1.1.jar differ
diff --git a/lib/GDB/neo4j/lucene-core-3.6.2.jar b/lib/GDB/neo4j/lucene-core-3.6.2.jar
new file mode 100644
index 00000000..cc374b70
Binary files /dev/null and b/lib/GDB/neo4j/lucene-core-3.6.2.jar differ
diff --git a/lib/GDB/neo4j/neo4j-backup-2.0.1.jar b/lib/GDB/neo4j/neo4j-backup-2.0.1.jar
new file mode 100644
index 00000000..fc85293e
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-backup-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-cluster-2.0.1.jar b/lib/GDB/neo4j/neo4j-cluster-2.0.1.jar
new file mode 100644
index 00000000..ae9de610
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-cluster-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-com-2.0.1.jar b/lib/GDB/neo4j/neo4j-com-2.0.1.jar
new file mode 100644
index 00000000..41c30ec7
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-com-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-consistency-check-2.0.1.jar b/lib/GDB/neo4j/neo4j-consistency-check-2.0.1.jar
new file mode 100644
index 00000000..8166b61a
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-consistency-check-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-cypher-2.0.1.jar b/lib/GDB/neo4j/neo4j-cypher-2.0.1.jar
new file mode 100644
index 00000000..871f28e5
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-cypher-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-cypher-commons-2.0.1.jar b/lib/GDB/neo4j/neo4j-cypher-commons-2.0.1.jar
new file mode 100644
index 00000000..20fd5f0f
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-cypher-commons-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-cypher-compiler-1.9-2.0.1.jar b/lib/GDB/neo4j/neo4j-cypher-compiler-1.9-2.0.1.jar
new file mode 100644
index 00000000..1b4580c6
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-cypher-compiler-1.9-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-cypher-compiler-2.0-2.0.1.jar b/lib/GDB/neo4j/neo4j-cypher-compiler-2.0-2.0.1.jar
new file mode 100644
index 00000000..f9067577
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-cypher-compiler-2.0-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-graph-algo-2.0.1.jar b/lib/GDB/neo4j/neo4j-graph-algo-2.0.1.jar
new file mode 100644
index 00000000..b98c24d6
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-graph-algo-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-graph-matching-2.0.1.jar b/lib/GDB/neo4j/neo4j-graph-matching-2.0.1.jar
new file mode 100644
index 00000000..2f2a11a7
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-graph-matching-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-ha-2.0.1.jar b/lib/GDB/neo4j/neo4j-ha-2.0.1.jar
new file mode 100644
index 00000000..6d7f9224
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-ha-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-jmx-2.0.1.jar b/lib/GDB/neo4j/neo4j-jmx-2.0.1.jar
new file mode 100644
index 00000000..5d811f93
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-jmx-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-kernel-2.0.1.jar b/lib/GDB/neo4j/neo4j-kernel-2.0.1.jar
new file mode 100644
index 00000000..b33f4b9b
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-kernel-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-lucene-index-2.0.1.jar b/lib/GDB/neo4j/neo4j-lucene-index-2.0.1.jar
new file mode 100644
index 00000000..ed16549e
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-lucene-index-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-management-2.0.1.jar b/lib/GDB/neo4j/neo4j-management-2.0.1.jar
new file mode 100644
index 00000000..11ae0cfa
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-management-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/neo4j-udc-2.0.1.jar b/lib/GDB/neo4j/neo4j-udc-2.0.1.jar
new file mode 100644
index 00000000..4e66353e
Binary files /dev/null and b/lib/GDB/neo4j/neo4j-udc-2.0.1.jar differ
diff --git a/lib/GDB/neo4j/netty-3.6.3.Final.jar b/lib/GDB/neo4j/netty-3.6.3.Final.jar
new file mode 100644
index 00000000..c046b7ce
Binary files /dev/null and b/lib/GDB/neo4j/netty-3.6.3.Final.jar differ
diff --git a/lib/GDB/neo4j/parboiled-core-1.1.6.jar b/lib/GDB/neo4j/parboiled-core-1.1.6.jar
new file mode 100644
index 00000000..9914e92b
Binary files /dev/null and b/lib/GDB/neo4j/parboiled-core-1.1.6.jar differ
diff --git a/lib/GDB/neo4j/parboiled-scala_2.10-1.1.6.jar b/lib/GDB/neo4j/parboiled-scala_2.10-1.1.6.jar
new file mode 100644
index 00000000..0942c8e2
Binary files /dev/null and b/lib/GDB/neo4j/parboiled-scala_2.10-1.1.6.jar differ
diff --git a/lib/GDB/neo4j/scala-library-2.10.3.jar b/lib/GDB/neo4j/scala-library-2.10.3.jar
new file mode 100644
index 00000000..069b1548
Binary files /dev/null and b/lib/GDB/neo4j/scala-library-2.10.3.jar differ
diff --git a/lib/GDB/orientdb/jna-4.0.0.jar b/lib/GDB/orientdb/jna-4.0.0.jar
new file mode 100644
index 00000000..9038048d
Binary files /dev/null and b/lib/GDB/orientdb/jna-4.0.0.jar differ
diff --git a/lib/GDB/orientdb/jna-platform-4.0.0.jar b/lib/GDB/orientdb/jna-platform-4.0.0.jar
new file mode 100644
index 00000000..4b3d567c
Binary files /dev/null and b/lib/GDB/orientdb/jna-platform-4.0.0.jar differ
diff --git a/lib/GDB/orientdb/orientdb-core-2.0.12.jar b/lib/GDB/orientdb/orientdb-core-2.0.12.jar
new file mode 100644
index 00000000..78ae47d0
Binary files /dev/null and b/lib/GDB/orientdb/orientdb-core-2.0.12.jar differ
diff --git a/lib/GDB/orientdb/orientdb-graphdb-2.0.12.jar b/lib/GDB/orientdb/orientdb-graphdb-2.0.12.jar
new file mode 100644
index 00000000..29eeb993
Binary files /dev/null and b/lib/GDB/orientdb/orientdb-graphdb-2.0.12.jar differ
diff --git a/lib/GDB/orientdb/orientdb-server-2.0.12.jar b/lib/GDB/orientdb/orientdb-server-2.0.12.jar
new file mode 100644
index 00000000..a32e6327
Binary files /dev/null and b/lib/GDB/orientdb/orientdb-server-2.0.12.jar differ
diff --git a/lib/GDB/orientdb/snappy-java-1.1.0.1.jar b/lib/GDB/orientdb/snappy-java-1.1.0.1.jar
new file mode 100644
index 00000000..3ef919f7
Binary files /dev/null and b/lib/GDB/orientdb/snappy-java-1.1.0.1.jar differ
diff --git a/src/dna/graph/BlueprintsGraph.java b/src/dna/graph/BlueprintsGraph.java
new file mode 100644
index 00000000..f4f3c279
--- /dev/null
+++ b/src/dna/graph/BlueprintsGraph.java
@@ -0,0 +1,1340 @@
+package dna.graph;
+
+import java.io.File;
+import java.math.BigInteger;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.lang.SystemUtils;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.lambdazen.bitsy.BitsyGraph;
+import com.orientechnologies.orient.core.Orient;
+import com.tinkerpop.blueprints.Direction;
+import com.tinkerpop.blueprints.Graph;
+import com.tinkerpop.blueprints.GraphFactory;
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph;
+import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
+import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
+
+import dna.graph.DNAGraphFactory.DNAGraphType;
+import dna.graph.datastructures.DataStructure.ListType;
+import dna.graph.datastructures.GraphDataStructure;
+import dna.graph.datastructures.IDataStructure;
+import dna.graph.edges.DirectedBlueprintsEdge;
+import dna.graph.edges.Edge;
+import dna.graph.edges.IGDBEdge;
+import dna.graph.edges.UndirectedBlueprintsEdge;
+import dna.graph.nodes.DirectedBlueprintsNode;
+import dna.graph.nodes.IGDBNode;
+import dna.graph.nodes.Node;
+import dna.graph.nodes.UndirectedBlueprintsNode;
+import dna.graph.weights.IWeighted;
+import dna.graph.weights.IWeightedEdge;
+import dna.graph.weights.IWeightedNode;
+import dna.util.IOUtils;
+import dna.util.Log;
+import dna.util.Rand;
+
+/**
+ * Wrapper class for graph databases that implement the tinkerpop blueprints
+ * interface com.tinkerpop.blueprints.Graph.
+ *
+ * @author Matthias
+ *
+ */
+
+public class BlueprintsGraph implements IGraph, IGDBGraph {
+
+ /** clear workspace for persistent graphs on close. */
+ private boolean clearWorkSpaceOnClose;
+
+ /** The edge count. */
+ private int edgeCount;
+
+ /** The edges. */
+ private HashMap edges = null;
+
+ /** The graph data structure. */
+ private GraphDataStructure gds;
+
+ /** The blueprints graph. */
+ private Graph graph;
+
+ /** The graph type. */
+ private DNAGraphFactory.DNAGraphType graphType;
+
+ /** The max node index. */
+ private int maxNodeIndex;
+
+ /** The name. */
+ private String name;
+
+ /** The node count. */
+ private int nodeCount;
+
+ /** The nodes. */
+ private HashMap nodes = null;
+
+ private Boolean storeDNAElementsInGDB = false;
+
+ /** The operations per commit. */
+ private int operationsPerCommit;
+
+ /** The operations since last commit. */
+ private int operationsSinceLastCommit;
+
+ /** The timestamp. */
+ private long timestamp;
+
+ /** The workspace dir. */
+ private String workspaceDir = null;
+
+ /**
+ * Instantiates a new blueprints graph.
+ *
+ * @param name the name of the graph
+ * @param timestamp the timestamp for the graph
+ * @param gds the graph data structure
+ * @param graphType
+ * the graph database type
+ * supported are:
+ *
+ * BITSY_DURABLE
+ * BITSY_NON_DURABLE
+ * NEO4J2
+ * ORIENTDBNOTX
+ * TINKERGRAPH
+ *
+ */
+ public BlueprintsGraph(String name, long timestamp, GraphDataStructure gds,
+ DNAGraphFactory.DNAGraphType graphType) {
+ this.init(name, timestamp, gds, 0, 0, graphType, 0, true, null, false);
+ }
+
+ /**
+ * Instantiates a new blueprints graph.
+ *
+ * @param name the name of the graph
+ * @param timestamp the timestamp for the graph
+ * @param gds the graphdatastructure
+ * @param graphType the graph database type
+ * supported are:
+ *
+ * BITSY_DURABLE
+ * BITSY_NON_DURABLE
+ * NEO4J2
+ * ORIENTDBNOTX
+ * TINKERGRAPH
+ *
+ * @param storeDNAElementsInGDB defines whether DNA elements (nodes, edges) should be stored in the
+ * graph database or not, if possible
+ * applies only for:
+ *
+ * BITSY_NON_DURABLE
+ * TINKERGRAPH
+ *
+ */
+ public BlueprintsGraph(String name, long timestamp, GraphDataStructure gds, DNAGraphFactory.DNAGraphType graphType,
+ Boolean storeDNAElementsInGDB) {
+ this.init(name, timestamp, gds, 0, 0, graphType, 0, false, "", storeDNAElementsInGDB);
+ }
+
+
+ /**
+ * Instantiates a new blueprints graph.
+ *
+ * @param graphType the graph database type
+ * supported are:
+ *
+ * BITSY_DURABLE
+ * BITSY_NON_DURABLE
+ * NEO4J2
+ * ORIENTDBNOTX
+ * TINKERGRAPH
+ *
+ * @param name the name of the graph
+ * @param timestamp the timestamp for the graph
+ * @param gds the graphdatastructure
+ * @param operationsPerCommit defines how many operations are executed
+ * till a commit will be executed
+ *
+ * X < 0:no commit
+ * X = 0:commit on close
+ * X > 0:commit every X operations
+ *
+ * @param clearWorkSpace clear workspace after the graph was closed
+ * applies only for :
+ *
+ * BITSY_DURABLE
+ * NEO4J2
+ *
+ * @param workspace the workspace directoy
+ * @param storeDNAElementsInGDB defines whether DNA elements (nodes, edges) should be stored in the
+ * graph database or not, if possible
+ * applies only for:
+ *
+ * BITSY_NON_DURABLE
+ * TINKERGRAPH
+ *
+ */
+ public BlueprintsGraph(String name, long timestamp, GraphDataStructure gds,
+ DNAGraphFactory.DNAGraphType graphType, int operationsPerCommit,
+ boolean clearWorkSpace, String workspace, Boolean storeDNAElementsInGDB) {
+ this.init(name, timestamp, gds, 0, 0, graphType, operationsPerCommit, clearWorkSpace, workspace, storeDNAElementsInGDB);
+ }
+
+ /**
+ * Instantiates a new blueprints graph.
+ *
+ * @param graphType the graph database type
+ * supported are:
+ *
+ * BITSY_DURABLE
+ * BITSY_NON_DURABLE
+ * NEO4J2
+ * ORIENTDBNOTX
+ * TINKERGRAPH
+ *
+ * @param name the name of the graph
+ * @param timestamp the timestamp for the graph
+ * @param gds the graphdatastructure
+ * @param nodeSize the number of nodes
+ * @param edgeSize the number of edges
+ * @param operationsPerCommit defines how many operations are executed
+ * till a commit will be executed
+ *
+ * X < 0:no commit
+ * X = 0:commit on close
+ * X > 0:commit every X operations
+ *
+ * @param clearWorkSpace clear workspace after the graph was closed
+ * applies only for :
+ *
+ * BITSY_DURABLE
+ * NEO4J2
+ *
+ * @param workspace the workspace directoy
+ * @param storeDNAElementsInGDB defines whether DNA elements (nodes, edges) should be stored in the
+ * graph database or not, if possible
+ * applies only for:
+ *
+ * BITSY_NON_DURABLE
+ * TINKERGRAPH
+ *
+ */
+ public BlueprintsGraph(String name, long timestamp, GraphDataStructure gds, int nodeSize, int edgeSize,
+ DNAGraphFactory.DNAGraphType graphType, int operationsPerCommit, boolean clearWorkSpace,
+ String workspace, Boolean storeDNAElementsInGDB) {
+ this.init(name, timestamp, gds, nodeSize, edgeSize, graphType, operationsPerCommit, clearWorkSpace, workspace, storeDNAElementsInGDB);
+ }
+
+ /**
+ * Instantiates a new blueprints graph.
+ *
+ * @param graphType the graph database type
+ * supported are:
+ *
+ * BITSY_DURABLE
+ * BITSY_NON_DURABLE
+ * NEO4J2
+ * ORIENTDBNOTX
+ * TINKERGRAPH
+ *
+ * @param name the name of the graph
+ * @param timestamp the timestamp for the graph
+ * @param gds the graphdatastructure
+ * @param nodeSize the number of nodes
+ * @param edgeSize the number of edges
+ */
+ public BlueprintsGraph(DNAGraphType graphType, String name, long timestamp, GraphDataStructure gds,
+ int nodeSize, int edgeSize) {
+ this.init(name, timestamp, gds, nodeSize, edgeSize, graphType, 0, false, "", false);
+ }
+
+ /**
+ * Returns the blueprints graph database describe with the .
+ *
+ * @param conf the configuration file
+ * @return the blueprints graph database
+ */
+ public static Graph getGDB(Configuration conf) {
+ return GraphFactory.open(conf);
+ }
+
+ /**
+ * Returns a new instance of a graph database which was given by the
+ * parameter 'graphType'.
+ *
+ * @param graphType the graph database type
+ * supported are:
+ *
+ * BITSY_DURABLE
+ * BITSY_NON_DURABLE
+ * NEO4J2
+ * ORIENTDBNOTX
+ * TINKERGRAPH
+ *
+ * @param name the name
+ * @param workspace the workspace
+ * @return a new instance of the {@link Graph}
+ */
+ public static Graph getGDB(DNAGraphType graphType, String name, String workspace) {
+ Configuration conf = new BaseConfiguration();
+
+ switch (graphType) {
+ case BITSY_DURABLE:
+ if (workspace == "") {
+ workspace = SystemUtils.getJavaIoTmpDir().getAbsolutePath()
+ + IOUtils.getPathForOS("/GDB/" + name + "/");
+ }
+ Path dbPath = Paths.get(workspace);
+
+ new File(dbPath.toAbsolutePath().toString()).mkdirs();
+ return new BitsyGraph(dbPath);
+ case BITSY_NON_DURABLE:
+ return new BitsyGraph();
+ case NEO4J2:
+ if (workspace == "") {
+ workspace = SystemUtils.getJavaIoTmpDir().getAbsolutePath()
+ + IOUtils.getPathForOS("/GDB/" + name + "/");
+ }
+
+ conf.setProperty("blueprints.graph", "com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph");
+ conf.setProperty("blueprints.neo4j.directory", workspace + name + "/");
+ break;
+ case ORIENTDBNOTX:
+ Orient.instance().startup();
+ conf.setProperty("blueprints.graph", "com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx");
+ conf.setProperty("blueprints.orientdb.url",
+ "memory:" + name + new Timestamp(System.currentTimeMillis()).toString());
+ break;
+ case TINKERGRAPH:
+ conf.setProperty("blueprints.graph", "com.tinkerpop.blueprints.impls.tg.TinkerGraph");
+ break;
+ default:
+ throw new RuntimeException("Choose a valid database!");
+ }
+ return GraphFactory.open(conf);
+ }
+
+ /**
+ * Returns the DNAGraphType to a given {@link Graph} instance.
+ *
+ * @param graph
+ * the graph instance
+ * @return the type of graph
+ */
+ public static DNAGraphType getTypeOfGraph(com.tinkerpop.blueprints.Graph graph) {
+ if (graph instanceof BitsyGraph)
+ if (((BitsyGraph) graph).isPersistent())
+ return DNAGraphType.BITSY_DURABLE;
+ else
+ return DNAGraphType.BITSY_NON_DURABLE;
+ else if (graph instanceof Neo4j2Graph)
+ return DNAGraphType.NEO4J2;
+ else if (graph instanceof OrientGraphNoTx)
+ return DNAGraphType.ORIENTDBNOTX;
+ else if (graph instanceof TinkerGraph)
+ return DNAGraphType.TINKERGRAPH;
+
+ return null;
+ }
+
+ /**
+ * Supported dna graph types.
+ *
+ * @return the collection
+ */
+ public static Collection supportedDNAGraphTypes() {
+ List result = new ArrayList();
+ result.add(DNAGraphType.BITSY_DURABLE);
+ result.add(DNAGraphType.BITSY_NON_DURABLE);
+ result.add(DNAGraphType.NEO4J2);
+ result.add(DNAGraphType.ORIENTDBNOTX);
+ result.add(DNAGraphType.TINKERGRAPH);
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#addEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean addEdge(Edge e) {
+ if (e == null || !(e instanceof IGDBEdge) || (e instanceof IGDBEdge && this.containsEdge(e))) {
+ return false;
+ }
+
+ Vertex src = (Vertex) ((IGDBNode>) e.getN1()).getGDBNode();
+ Vertex dst = (Vertex) ((IGDBNode>) e.getN2()).getGDBNode();
+ com.tinkerpop.blueprints.Edge edge = this.graph.addEdge(null, src, dst, "IGDBEdge");
+
+ if (edge != null) {
+ // commit
+ operationsSinceLastCommit++;
+ if (operationsPerCommit == operationsSinceLastCommit && this.graphType != DNAGraphType.BITSY_DURABLE
+ && this.graphType != DNAGraphType.BITSY_NON_DURABLE) {
+ this.commit();
+ operationsSinceLastCommit = 0;
+ }
+
+ this.edgeCount++;
+
+ if (e instanceof DirectedBlueprintsEdge)
+ ((DirectedBlueprintsEdge) e).setGDBEdgeId(edge.getId());
+ else if (e instanceof UndirectedBlueprintsEdge)
+ ((UndirectedBlueprintsEdge) e).setGDBEdgeId(edge.getId());
+
+ ((IGDBEdge>) e).setGraph(this);
+
+ edge.setProperty("directed", this.isDirected());
+
+ if (e instanceof IWeightedEdge) {
+ edge.setProperty("weight", ((IWeighted) e).getWeight().asString());
+ }
+
+ if (this.storeInGDB()) {
+ edge.setProperty("edge", e);
+ } else {
+ edges.put(edge.getId(), e);
+ }
+
+ src = null;
+ dst = null;
+ edge = null;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#addNode(dna.graph.nodes.Node)
+ */
+ @Override
+ public boolean addNode(Node n) {
+ if (n == null || !(n instanceof IGDBNode) || (n instanceof IGDBNode && this.containsNode(n))) {
+ return false;
+ }
+
+ Vertex vertex = this.graph.addVertex(null);
+
+ if (vertex != null) {
+ // commit
+ operationsSinceLastCommit++;
+ if (operationsPerCommit == operationsSinceLastCommit && this.graphType != DNAGraphType.BITSY_DURABLE
+ && this.graphType != DNAGraphType.BITSY_NON_DURABLE) {
+ this.commit();
+ operationsSinceLastCommit = 0;
+ }
+
+ this.nodeCount++;
+
+ if (n.getIndex() > this.maxNodeIndex) {
+ this.maxNodeIndex = n.getIndex();
+ }
+
+ if (n instanceof DirectedBlueprintsNode) {
+ ((DirectedBlueprintsNode) n).setGDBNodeId(vertex.getId());
+ } else if (n instanceof UndirectedBlueprintsNode) {
+ ((UndirectedBlueprintsNode) n).setGDBNodeId(vertex.getId());
+ }
+
+ ((IGDBNode>) n).setGraph(this);
+
+ vertex.setProperty("index", n.getIndex());
+ vertex.setProperty("directed", this.isDirected());
+
+ if (n instanceof IWeightedNode) {
+ vertex.setProperty("weight", ((IWeighted) n).getWeight().asString());
+ }
+
+ if (this.storeInGDB()) {
+ vertex.setProperty("node", n);
+ } else {
+ nodes.put(vertex.getId(), n);
+ }
+
+ vertex = null;
+ n = null;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Defines whether or not the workspace should be cleared.
+ *
+ * @return the clearWorkSpaceOnClose
+ */
+ public boolean clearWorkSpaceOnClose() {
+ return clearWorkSpaceOnClose;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#close()
+ */
+ @Override
+ public void close() {
+ if (this.graph != null) {
+ if (operationsPerCommit >= 0)
+ this.commit();
+
+ switch (graphType) {
+ case ORIENTDBNOTX:
+ ((OrientGraphNoTx) this.graph).drop();
+ this.graph.shutdown();
+ if (Orient.instance().getStorages().isEmpty())
+ Orient.instance().shutdown();
+ break;
+ default:
+ this.graph.shutdown();
+ break;
+ }
+
+ if (clearWorkSpaceOnClose()) {
+ try {
+ if (workspaceDir != null && !(workspaceDir.trim().isEmpty())) {
+ File workSpaceDir = new File(this.workspaceDir);
+ if (workSpaceDir.exists())
+ IOUtils.removeRecursive(workSpaceDir.getAbsolutePath(), 10);
+ }
+ } catch (Exception ex) {
+
+ }
+ }
+ }
+ this.graph = null;
+ System.gc();
+ System.gc();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGDBGraph#commit()
+ */
+ @Override
+ public void commit() {
+ switch (graphType) {
+ case BITSY_DURABLE:
+ case BITSY_NON_DURABLE:
+ ((BitsyGraph) this.graph).commit();
+ break;
+ case NEO4J2:
+ ((Neo4j2Graph) this.graph).commit();
+ break;
+ case ORIENTDBNOTX:
+ ((OrientGraphNoTx) this.graph).commit();
+ break;
+ case TINKERGRAPH:
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#containsEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean containsEdge(Edge edge) {
+ if (edge instanceof IGDBEdge)
+ return containsEdge(edge.getN1(), edge.getN2());
+
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#containsEdge(int, int)
+ */
+ @Override
+ public boolean containsEdge(int n1, int n2) {
+ return containsEdge(getNode(n1), getNode(n2));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#containsEdge(dna.graph.nodes.Node,
+ * dna.graph.nodes.Node)
+ */
+ @Override
+ public boolean containsEdge(Node n1, Node n2) {
+ if (n1 instanceof IGDBNode> && n2 instanceof IGDBNode>) {
+ return containsEdge((Vertex) ((IGDBNode>) n1).getGDBNode(), (Vertex) ((IGDBNode>) n2).getGDBNode());
+ }
+
+ return false;
+ }
+
+ /**
+ * Contains edge.
+ *
+ * @param v1 vertex 1
+ * @param v2 vertex 2
+ * @return true, if successful
+ */
+ private boolean containsEdge(Vertex v1, Vertex v2) {
+ if (v1 == null || v2 == null)
+ return false;
+
+ return getEdge(v1, v2) != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#containsNode(dna.graph.nodes.Node)
+ */
+ @Override
+ public boolean containsNode(Node n) {
+ if (n instanceof IGDBNode) {
+ return ((IGDBNode>) n).getGDBNode() != null
+ && this.graph.getVertex(((Vertex) ((IGDBNode>) n).getGDBNode()).getId()) != null;
+ }
+
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#containsNodes(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean containsNodes(Edge e) {
+ if (this.isDirected()) {
+ if (e instanceof DirectedBlueprintsEdge) {
+ return containsNode(((DirectedBlueprintsEdge) e).getDst())
+ && containsNode(((DirectedBlueprintsEdge) e).getSrc());
+ }
+ } else if (e instanceof UndirectedBlueprintsEdge) {
+ return containsNode(((UndirectedBlueprintsEdge) e).getNode1())
+ && containsNode(((UndirectedBlueprintsEdge) e).getNode2());
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ Log.debug("Running equality check for graphs");
+
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ BlueprintsGraph other = (BlueprintsGraph) obj;
+
+ if (gds == null) {
+ if (other.gds != null) {
+ return false;
+ }
+ } else if (!gds.equals(other.gds)) {
+ return false;
+ }
+ if (timestamp != other.timestamp) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ Log.debug("Basics equal, going for edges and nodes");
+
+ if (getEdges() == null) {
+ if (other.getEdges() != null) {
+ return false;
+ }
+ } else if (!Iterables.elementsEqual(getEdges(), other.getEdges())) {
+ Log.debug("Edges not equal (type: " + getEdges().getClass() + ")");
+ return false;
+ }
+ if (getNodes() == null) {
+ if (other.getNodes() != null) {
+ return false;
+ }
+ } else if (!Iterables.elementsEqual(getNodes(), other.getNodes())) {
+ Log.debug("Nodes not equal (type: " + getNodes().getClass() + ")");
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ close();
+ } finally {
+ super.finalize();
+ }
+ }
+
+ /**
+ * Gets the edge.
+ *
+ * @param e
+ * the e
+ * @return the edge
+ */
+ public Edge getEdge(com.tinkerpop.blueprints.Edge e) {
+ if (e != null) {
+ if (this.storeInGDB()) {
+ return e.getProperty("edge");
+ } else {
+ return (Edge) edges.get(e.getId());
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getEdge(dna.graph.nodes.Node, dna.graph.nodes.Node)
+ */
+ @Override
+ public Edge getEdge(Node n1, Node n2) {
+ Iterable gdbEdges = this.graph.getEdges();
+ Vertex src = null;
+ Vertex dst = null;
+
+ try {
+ for (com.tinkerpop.blueprints.Edge e : gdbEdges) {
+ src = e.getVertex(Direction.OUT);
+ dst = e.getVertex(Direction.IN);
+
+ if ((int) src.getProperty("index") == n1.getIndex()
+ && (int) dst.getProperty("index") == n2.getIndex()) {
+
+ return getEdge(e);
+ }
+ }
+
+ return null;
+ } finally {
+ gdbEdges = null;
+ src = null;
+ dst = null;
+ }
+ }
+
+ /**
+ * Gets the edge.
+ *
+ * @param v1 the first node
+ * @param v2 the second node
+ * @return the edge
+ */
+ private Edge getEdge(Vertex v1, Vertex v2) {
+ Iterable edges = v1.getEdges(Direction.OUT, "IGDBEdge");
+ try {
+ for (com.tinkerpop.blueprints.Edge e : edges) {
+ if (e.getVertex(Direction.IN).equals(v2))
+ return getEdge(e);
+ }
+
+ return null;
+ } finally {
+ edges = null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getEdgeCount()
+ */
+ @Override
+ public int getEdgeCount() {
+ return this.edgeCount;
+ }
+
+ /**
+ * Gets the edge count from db.
+ *
+ * @return the edge count from db
+ */
+ public int getEdgeCountFromDB() {
+ return Iterables.size(this.graph.getEdges());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getEdges()
+ */
+ @Override
+ public Iterable getEdges() {
+ if (!this.storeInGDB()) {
+ return edges.values();
+ }
+
+ return Iterables.transform(this.graph.getEdges(), new Function() {
+ @Override
+ public IElement apply(final com.tinkerpop.blueprints.Edge input) {
+ return getEdge(input);
+ }
+ });
+ }
+
+ /**
+ * Returns the graph database edge associated with the given id.
+ *
+ * @param gbdEdgeId the graph database edge id
+ * @return the graph database edge
+ */
+ public com.tinkerpop.blueprints.Edge getGDBEdge(Object gdbEdgeId) {
+ if (this.graph == null || gdbEdgeId == null)
+ return null;
+ else
+ return this.graph.getEdge(gdbEdgeId);
+ }
+
+ /**
+ * Returns the graph database node associated with the given id.
+ *
+ * @param gdbNodeId the graph database node id
+ * @return the graph database node
+ */
+ public Vertex getGDBNode(Object gdbNodeId) {
+ if (this.graph == null || gdbNodeId == null)
+ return null;
+ else
+ return this.graph.getVertex(gdbNodeId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGDBGraph#getGraphDatabaseInstance()
+ */
+ @Override
+ public Graph getGraphDatabaseInstance() {
+ return this.graph;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGDBGraph#getGraphDatabaseType()
+ */
+ @Override
+ public DNAGraphType getGraphDatabaseType() {
+ return this.graphType;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getGraphDatastructures()
+ */
+ @Override
+ public GraphDataStructure getGraphDatastructures() {
+ return this.gds;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getType()
+ */
+ @Override
+ public DNAGraphType getInstanceType() {
+ return this.graphType;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getMaxEdgeCount()
+ */
+ @Override
+ public BigInteger getMaxEdgeCount() {
+ int nodeCnt = this.getNodeCount();
+
+ BigInteger res = BigInteger.valueOf(nodeCnt);
+ res = res.multiply(BigInteger.valueOf(nodeCnt - 1));
+ if (!this.isDirected()) {
+ res = res.divide(BigInteger.valueOf(2));
+ }
+ return res;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getMaxNodeIndex()
+ */
+ @Override
+ public int getMaxNodeIndex() {
+ return this.maxNodeIndex;
+ }
+
+ /**
+ * Gets the max node index from db.
+ *
+ * @return the max node index from db
+ */
+ public int getMaxNodeIndexFromDB() {
+ int max = -1;
+ for (IElement node : this.getNodes()) {
+ maxNodeIndex = Math.max(max, ((Node) node).getIndex());
+ }
+ return max;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getName()
+ */
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getNode(int)
+ */
+ @Override
+ public Node getNode(int index) {
+ Iterable vertices = this.graph.getVertices("index", index);
+
+ //at most one Vertex should be included
+ Vertex v = Iterables.getFirst(vertices, null);
+
+ return v == null ? null : getNode(v);
+ }
+
+ /**
+ * Returns the node associated with the vertex.
+ *
+ * @param v vertex
+ * @return the node
+ */
+ public Node getNode(Vertex v) {
+ if (v != null) {
+ if (this.storeInGDB()) {
+ return v.getProperty("node");
+ } else {
+ return (Node) nodes.get(v.getId());
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getNodeCount()
+ */
+ @Override
+ public int getNodeCount() {
+ return nodeCount;
+ }
+
+ /**
+ * Gets the node count from database.
+ *
+ * @return the node count from database
+ */
+ public int getNodeCountFromDB() {
+ return Iterables.size(this.graph.getVertices());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getNodes()
+ */
+ @Override
+ public Iterable getNodes() {
+ if (!this.storeInGDB()) {
+ return nodes.values();
+ }
+
+ return Iterables.transform(this.graph.getVertices(), new Function() {
+ @Override
+ public IElement apply(final Vertex input) {
+ return getNode(input);
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getRandomEdge()
+ */
+ @Override
+ public Edge getRandomEdge() {
+ if (getEdgeCount() <= 0)
+ return null;
+
+ if (this.storeInGDB()) {
+ Iterable gdbEdges = this.graph.getEdges();
+
+ com.tinkerpop.blueprints.Edge edge = Iterables.get(gdbEdges, Rand.rand.nextInt(Iterables.size(gdbEdges)));
+ while (edge == null) {
+ edge = Iterables.get(gdbEdges, Rand.rand.nextInt(Iterables.size(gdbEdges)));
+ }
+ return getEdge(edge);
+ } else {
+ return (Edge) Iterables.get(edges.values(), Rand.rand.nextInt(edges.size()));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getRandomNode()
+ */
+ @Override
+ public Node getRandomNode() {
+ if (getNodeCount() <= 0)
+ return null;
+
+ if (this.storeInGDB()) {
+ Iterable gdbVertices = this.graph.getVertices();
+
+ Vertex vertex = Iterables.get(gdbVertices, Rand.rand.nextInt(Iterables.size(gdbVertices)));
+ while (vertex == null) {
+ vertex = Iterables.get(gdbVertices, Rand.rand.nextInt(Iterables.size(gdbVertices)));
+ }
+ return getNode(vertex);
+ } else {
+ return (Node) Iterables.get(nodes.values(), Rand.rand.nextInt(nodes.size()));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#getTimestamp()
+ */
+ @Override
+ public long getTimestamp() {
+ return this.timestamp;
+ }
+
+ /**
+ * Gets the workspace dir.
+ *
+ * @return the workspace
+ */
+ public String getWorkspaceDir() {
+ return workspaceDir;
+ }
+
+ /**
+ * Initialize all necessary variables.
+ *
+ * @param name the name of the graph
+ * @param timestamp the timestamp for the graph
+ * @param gds the graphdatastructure
+ * @param graphType the graph database type
+ * supported are:
+ *
+ * BITSY_DURABLE
+ * BITSY_NON_DURABLE
+ * NEO4J2
+ * ORIENTDBNOTX
+ * TINKERGRAPH
+ *
+ * @param operationsPerCommit defines how many operations are executed
+ * till a commit will be executed
+ *
+ * X < 0:no commit
+ * X = 0:commit on close
+ * X > 0:commit every X operations
+ *
+ * @param clearWorkSpaceOnClose the clear work space on close
+ * @param workspace the workspace directoy
+ */
+ private void init(String name, long timestamp, GraphDataStructure gds, int nodeSize, int edgeSize,
+ DNAGraphType graphType, int operationsPerCommit, boolean clearWorkSpaceOnClose,
+ String workspace, Boolean storeDNAElementsInGDB) {
+ this.name = name;
+ this.timestamp = timestamp;
+ this.gds = gds;
+ this.graphType = graphType;
+ this.maxNodeIndex = -1;
+ this.nodeCount = 0;
+ this.edgeCount = 0;
+ this.operationsPerCommit = operationsPerCommit;
+ this.operationsSinceLastCommit = 0;
+ this.storeDNAElementsInGDB = storeDNAElementsInGDB;
+ this.clearWorkSpaceOnClose = clearWorkSpaceOnClose;
+ this.workspaceDir = workspace;
+ if (!this.storeInGDB()) {
+ // Vertex.getId() --> Node
+ nodes = new HashMap(nodeSize <= 0 ? 16 : nodeSize);
+ // Edge.getId() --> Edge
+ edges = new HashMap(edgeSize <= 0 ? 16 : edgeSize);
+ }
+ this.graph = BlueprintsGraph.getGDB(this.graphType, name, workspace);
+ }
+
+ private boolean storeInGDB()
+ {
+ return this.graphType.supportsObjectAsProperty() && storeDNAElementsInGDB;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#isDirected()
+ */
+ @Override
+ public boolean isDirected() {
+ return gds.createsDirected();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#print()
+ */
+ @Override
+ public void print() {
+ System.out.println(this.toString());
+ System.out.println(" V = " + this.getNodes());
+ System.out.println(" E = " + this.getEdges());
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#printAll()
+ */
+ @Override
+ public void printAll() {
+ System.out.println(this.toString());
+ printV();
+ printE();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#printE()
+ */
+ @Override
+ public void printE() {
+ System.out.println(this.toString());
+ Iterator iterator = this.getEdges().iterator();
+ while (iterator.hasNext()) {
+ System.out.println(" " + iterator.next());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#printV()
+ */
+ @Override
+ public void printV() {
+ System.out.println(this.toString());
+ Iterator iterator = this.getNodes().iterator();
+ while (iterator.hasNext()) {
+ System.out.println(" " + iterator.next());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#removeEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean removeEdge(Edge e) {
+ if (!(e instanceof IGDBEdge))
+ return false;
+
+ com.tinkerpop.blueprints.Edge edge = (com.tinkerpop.blueprints.Edge) ((IGDBEdge>) e).getGDBEdge();
+
+ if (edge == null)
+ return false;
+
+ this.graph.removeEdge(edge);
+
+ if (!this.storeInGDB()) {
+ edges.remove(edge.getId());
+ }
+
+ if (this.getGraphDatabaseType() == DNAGraphType.NEO4J2) {
+ this.commit();
+ }
+
+ if (this.graph.getEdge(edge.getId()) == null) {
+ ((IGDBEdge>) e).setGDBEdgeId(null);
+ this.edgeCount--;
+ return true;
+ }
+
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#removeNode(dna.graph.nodes.Node)
+ */
+ @Override
+ public boolean removeNode(Node n) {
+
+ if (!(n instanceof IGDBNode))
+ return false;
+
+ Vertex v = (Vertex) ((IGDBNode>) n).getGDBNode();
+
+ if (v == null)
+ return false;
+
+ this.graph.removeVertex(v);
+
+ if (this.getGraphDatabaseType() == DNAGraphType.NEO4J2) {
+ this.commit();
+ }
+
+ if (this.graph.getVertex(v.getId()) == null) {
+ ((IGDBNode>) n).setGDBNodeId(null);
+
+ if (!this.storeInGDB()) {
+ nodes.remove(v.getId());
+ }
+
+ if (n.getIndex() == this.maxNodeIndex) {
+ this.maxNodeIndex = this.getMaxNodeIndexFromDB();
+ }
+ v = null;
+ nodeCount--;
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Sets the clear work space on close.
+ *
+ * @param clearWorkSpaceOnClose the clearWorkSpaceOnClose to set
+ */
+ public void setClearWorkSpaceOnClose(boolean clearWorkSpaceOnClose) {
+ this.clearWorkSpaceOnClose = clearWorkSpaceOnClose;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * dna.graph.IGDBGraph#setGraphDatabaseInstance(com.tinkerpop.blueprints.
+ * Graph)
+ */
+ /*
+ */
+ @Override
+ public void setGraphDatabaseInstance(Graph graph) {
+ this.graph = graph;
+ this.graphType = BlueprintsGraph.getTypeOfGraph(graph);
+ this.maxNodeIndex = this.getMaxNodeIndexFromDB();
+ this.nodeCount = this.getNodeCountFromDB();
+ this.edgeCount = this.getEdgeCountFromDB();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGDBGraph#setGraphDatabaseType(dna.graph.DNAGraphFactory.
+ * DNAGraphType)
+ */
+ @Override
+ public void setGraphDatabaseType(DNAGraphType gdb) {
+ this.graphType = gdb;
+ this.graph = BlueprintsGraph.getGDB(gdb, this.name, "");
+ this.maxNodeIndex = this.getMaxNodeIndexFromDB();
+ this.nodeCount = this.getNodeCountFromDB();
+ this.edgeCount = this.getEdgeCountFromDB();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#setName(java.lang.String)
+ */
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#setTimestamp(long)
+ */
+ @Override
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.IGraph#switchDataStructure(dna.graph.datastructures.
+ * DataStructure.ListType, java.lang.Class)
+ */
+ @Override
+ public void switchDataStructure(ListType type, Class extends IDataStructure> newDatastructureType) {
+ Log.warn("Switching datastructure is not possible for " + this.getClass().getName());
+ }
+}
diff --git a/src/dna/graph/DNAGraphFactory.java b/src/dna/graph/DNAGraphFactory.java
new file mode 100644
index 00000000..f6d200b3
--- /dev/null
+++ b/src/dna/graph/DNAGraphFactory.java
@@ -0,0 +1,321 @@
+package dna.graph;
+
+import dna.graph.datastructures.GraphDataStructure;
+import dna.util.Config;
+
+/**
+ * A factory for creating DNAGraph objects.
+ */
+public class DNAGraphFactory {
+
+ /**
+ * The Enum DNAGraphType.
+ */
+ public enum DNAGraphType {
+
+ /** The bitsy graph databse (durable, stores data on disk). */
+ BITSY_DURABLE("Bitsy graph database", false),
+
+ /** The bitsy graph database (in memory only). */
+ BITSY_NON_DURABLE("Bitsy graph database", true),
+
+ /** Read graph database from the config file. */
+ CONFIG("Read graph properties from config file", true),
+
+ /** The standard DNA graph type. */
+ DNA("The standard DNA Graph", false),
+
+ /** The Neo4J2 graph database. */
+ NEO4J2("Neo4j graph database", false),
+
+ /** The OrientDB graph database with no transaction. */
+ ORIENTDBNOTX("OrientDB graph database without transactions", false),
+
+ /**
+ * The Tinkergraph graph database (reference implementation from
+ * Tinkerpop Blueprints).
+ */
+ TINKERGRAPH("Tinkergraph graph database", true);
+
+ /** The description. */
+ private final String description;
+
+ /** The supports object as property. */
+ private final Boolean supportsObjectAsProperty;
+
+ /**
+ * Instantiates a new DNA graph type.
+ *
+ * @param description
+ * the description
+ * @param supportsObjectAsProperty
+ * the supports object as property
+ */
+ private DNAGraphType(String description, Boolean supportsObjectAsProperty) {
+ this.description = description;
+ this.supportsObjectAsProperty = supportsObjectAsProperty;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Supports object as property.
+ *
+ * @return true, if database supports java objects as properties
+ */
+ public Boolean supportsObjectAsProperty() {
+ return this.supportsObjectAsProperty;
+ }
+ }
+
+ /** Clear work space. */
+ private static boolean clearWorkSpace = false;
+
+ /** The operations per commit. */
+ private static int operationsPerCommit = 0;
+
+ /** Store DNA elements (nodes, edges) in the graph database, if possible */
+ private static boolean storeDNAElementsInGDB = false;
+
+ /** The type. */
+ private static DNAGraphType type = null;
+
+ /** The workspace. */
+ private static String workspace = null;
+
+ /**
+ * Checks if the graph type and graph data structure are compatible.
+ *
+ * @param graphType
+ * the graph type
+ * @param gds
+ * the graph data structure
+ * @return true, if compatible
+ */
+ public static boolean areCombatible(DNAGraphType graphType, GraphDataStructure gds) {
+ return graphType == DNAGraphType.DNA && !gds.usesGraphDatabase()
+ || !(graphType == DNAGraphType.DNA) && gds.usesGraphDatabase();
+ }
+
+ /**
+ * Creates a new graph instance of the given type with specified parameters.
+ *
+ * @param graphType
+ * the graph type
+ * @param name
+ * the name
+ * @param timestamp
+ * the timestamp
+ * @param gds
+ * the graph data structure
+ * @return a new graph instance
+ */
+ public static IGraph newGraphInstance(DNAGraphType graphType, String name, long timestamp, GraphDataStructure gds) {
+ if (!DNAGraphFactory.areCombatible(graphType, gds)) {
+ throw new RuntimeException(
+ "The chosen graph type and the node type for the graph datastructure are incompatible.");
+ }
+
+ switch (graphType) {
+ case CONFIG:
+ readValuesFromConfig();
+ if (DNAGraphType.CONFIG.equals(type)){
+ throw new RuntimeException(
+ "It is prohibited to specify 'CONFIG' as graph type in the configuration file.");
+ }
+ return newGraphInstance(type, name, timestamp, gds, 0, 0, operationsPerCommit, clearWorkSpace, workspace,
+ storeDNAElementsInGDB);
+ case DNA:
+ return new Graph(name, timestamp, gds);
+ case BITSY_DURABLE:
+ case BITSY_NON_DURABLE:
+ case NEO4J2:
+ case ORIENTDBNOTX:
+ case TINKERGRAPH:
+ return new BlueprintsGraph(name, timestamp, gds, graphType);
+ default:
+ throw new RuntimeException("Choose a valid DNA graph type!");
+ }
+ }
+
+ /**
+ * Creates a new graph instance of the given type with specified parameters.
+ *
+ * @param graphType the graph type
+ * @param name the name
+ * @param timestamp the timestamp
+ * @param gds the graph data structure
+ * @param operationsPerCommit defines the number of operations until a commit will be
+ * executed
+ * @param clearWorkSpace defines whether the work space should be cleared on close or
+ * not
+ * @param workSpace the path to the working directory
+ * @param storeDNAElementsInGDB the store dna elements in gdb
+ * @return a new graph instance
+ */
+ public static IGraph newGraphInstance(DNAGraphType graphType, String name, long timestamp, GraphDataStructure gds,
+ int operationsPerCommit, boolean clearWorkSpace, String workSpace, boolean storeDNAElementsInGDB) {
+ if (!DNAGraphFactory.areCombatible(graphType, gds)) {
+ throw new RuntimeException(
+ "The chosen graph type and the node type for the graph datastructure are incompatible.");
+ }
+
+ switch (graphType) {
+ case CONFIG:
+ readValuesFromConfig();
+ if (DNAGraphType.CONFIG.equals(type)){
+ throw new RuntimeException("It is prohibited to specify 'CONFIG' as graph type in the configuration file.");
+ }
+ return newGraphInstance(type, name, timestamp, gds, operationsPerCommit, clearWorkSpace,
+ workSpace, storeDNAElementsInGDB);
+ case DNA:
+ return new Graph(name, timestamp, gds);
+ case BITSY_DURABLE:
+ case BITSY_NON_DURABLE:
+ case NEO4J2:
+ case ORIENTDBNOTX:
+ case TINKERGRAPH:
+ return new BlueprintsGraph(name, timestamp, gds, graphType, operationsPerCommit,
+ clearWorkSpace, workSpace, storeDNAElementsInGDB);
+ default:
+ throw new RuntimeException("Choose a valid DNA graph type!");
+ }
+ }
+
+ /**
+ * Creates a new graph instance of the given type with specified parameters.
+ *
+ * @param graphType
+ * the graph type
+ * @param name
+ * the name
+ * @param timestamp
+ * the timestamp
+ * @param gds
+ * the graph data structure
+ * @param operationsPerCommit
+ * defines the number of operations until a commit will be
+ * executed
+ * @param clearWorkSpace
+ * defines whether the work space should be cleared on close or
+ * not
+ * @param workSpace
+ * the path to the working directory
+ * @return a new graph instance
+ */
+ public static IGraph newGraphInstance(DNAGraphType graphType, String name, long timestamp, GraphDataStructure gds,
+ int nodeSize, int edgeSize, int operationsPerCommit, boolean clearWorkSpace, String workSpace,
+ boolean storeDNAElementsInGDB) {
+ if (!DNAGraphFactory.areCombatible(graphType, gds)) {
+ throw new RuntimeException(
+ "The chosen graph type and the node type for the graph datastructure are incompatible.");
+ }
+
+ switch (graphType) {
+ case CONFIG:
+ readValuesFromConfig();
+ if (DNAGraphType.CONFIG.equals(type)){
+ throw new RuntimeException(
+ "It is prohibited to specify 'CONFIG' as graph type in the configuration file.");
+ }
+ return newGraphInstance(type, name, timestamp, gds, nodeSize, edgeSize, operationsPerCommit, clearWorkSpace,
+ workSpace, storeDNAElementsInGDB);
+ case DNA:
+ return new Graph(name, timestamp, gds, nodeSize, edgeSize);
+ case BITSY_DURABLE:
+ case BITSY_NON_DURABLE:
+ case NEO4J2:
+ case ORIENTDBNOTX:
+ case TINKERGRAPH:
+ return new BlueprintsGraph(name, timestamp, gds, nodeSize, edgeSize, graphType, operationsPerCommit,
+ clearWorkSpace, workSpace, storeDNAElementsInGDB);
+ default:
+ throw new RuntimeException("Choose a valid DNA graph type!");
+ }
+ }
+
+ /**
+ * Creates a new graph instance of the given type with specified parameters.
+ *
+ * @param graphType
+ * the graph type
+ * @param name
+ * the name
+ * @param timestamp
+ * the timestamp
+ * @param gds
+ * the graph data structure
+ * @param nodeSize
+ * the number of nodes
+ * @param edgeSize
+ * the number of edges
+ * @return a new graph instance
+ */
+ public static IGraph newGraphInstance(DNAGraphType graphType, String name, long timestamp, GraphDataStructure gds,
+ int nodeSize, int edgeSize) {
+ if (!DNAGraphFactory.areCombatible(graphType, gds)) {
+ throw new RuntimeException(
+ "The chosen graph type and the node type for the graph datastructure are incompatible.");
+ }
+
+ switch (graphType) {
+ case CONFIG:
+ readValuesFromConfig();
+ if (DNAGraphType.CONFIG.equals(type)){
+ throw new RuntimeException(
+ "It is prohibited to specify 'CONFIG' as graph type in the configuration file.");
+ }
+ return newGraphInstance(type, name, timestamp, gds, nodeSize, edgeSize, operationsPerCommit, clearWorkSpace,
+ workspace, storeDNAElementsInGDB);
+ case DNA:
+ return new Graph(name, timestamp, gds, nodeSize, edgeSize);
+ case BITSY_DURABLE:
+ case BITSY_NON_DURABLE:
+ case NEO4J2:
+ case ORIENTDBNOTX:
+ case TINKERGRAPH:
+ return new BlueprintsGraph(graphType, name, timestamp, gds, nodeSize, edgeSize);
+ default:
+ throw new RuntimeException("Choose a valid DNA graph type!");
+ }
+ }
+
+ /**
+ * Read values from configuration file.
+ */
+ private static void readValuesFromConfig() {
+ try {
+ type = Enum.valueOf(DNAGraphType.class, Config.get("GF_GRAPHTYPE").trim());
+ } catch (Exception ex) {
+ type = null;
+ }
+ try {
+ operationsPerCommit = Integer.parseInt(Config.get("GF_GDB_OPERATIONS_PER_COMMIT").trim());
+ } catch (Exception ex) {
+ operationsPerCommit = 0;
+ }
+ try {
+ clearWorkSpace = Boolean.parseBoolean(Config.get("GF_GDB_CLEAR_WORKSPACE_ON_CLOSE").trim());
+ } catch (Exception ex) {
+ clearWorkSpace = false;
+ }
+ try {
+ workspace = Config.get("GF_GDB_WORKSPACE").trim();
+ } catch (Exception ex) {
+ workspace = null;
+ }
+ try {
+ storeDNAElementsInGDB = Boolean.parseBoolean(Config.get("GF_GDB_STORE_DNA_ELEMENTS_IN_GDB").trim());
+ } catch (Exception ex) {
+ storeDNAElementsInGDB = false;
+ }
+ }
+
+}
diff --git a/src/dna/graph/Graph.java b/src/dna/graph/Graph.java
index ae08989d..75e267d1 100644
--- a/src/dna/graph/Graph.java
+++ b/src/dna/graph/Graph.java
@@ -5,7 +5,7 @@
import com.google.common.collect.Iterables;
-import dna.graph.datastructures.DataStructure.ListType;
+import dna.graph.DNAGraphFactory.DNAGraphType;import dna.graph.datastructures.DataStructure.ListType;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.IDataStructure;
import dna.graph.datastructures.IEdgeListDatastructure;
@@ -28,7 +28,7 @@
* @author Nico
*
*/
-public class Graph {
+public class Graph implements IGraph{
public INodeListDatastructure nodes;
public IEdgeListDatastructure edges;
private String name;
@@ -364,4 +364,14 @@ public void switchDataStructure(ListType type,
}
}
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public DNAGraphType getInstanceType() {
+ return DNAGraphType.DNA;
+ }
}
diff --git a/src/dna/graph/IGDBGraph.java b/src/dna/graph/IGDBGraph.java
new file mode 100644
index 00000000..cd7d2b4a
--- /dev/null
+++ b/src/dna/graph/IGDBGraph.java
@@ -0,0 +1,42 @@
+package dna.graph;
+
+/**
+ * The Interface IGDBGraph.
+ *
+ * @author Matthias
+ */
+public interface IGDBGraph {
+
+ /**
+ * Commit.
+ */
+ public abstract void commit();
+
+ /**
+ * Gets the graph database instance.
+ *
+ * @return the graph database instance
+ */
+ public abstract G getGraphDatabaseInstance();
+
+ /**
+ * Gets the graph database type.
+ *
+ * @return the graph database type
+ */
+ public abstract DNAGraphFactory.DNAGraphType getGraphDatabaseType();
+
+ /**
+ * Sets the graph database instance.
+ *
+ * @param graph the new graph database instance
+ */
+ public abstract void setGraphDatabaseInstance(G graph);
+
+ /**
+ * Sets the graph database type.
+ *
+ * @param gdb the new graph database type
+ */
+ public abstract void setGraphDatabaseType(DNAGraphFactory.DNAGraphType gdb);
+}
diff --git a/src/dna/graph/IGraph.java b/src/dna/graph/IGraph.java
new file mode 100644
index 00000000..b511d059
--- /dev/null
+++ b/src/dna/graph/IGraph.java
@@ -0,0 +1,267 @@
+package dna.graph;
+
+import java.math.BigInteger;
+
+import dna.graph.DNAGraphFactory.DNAGraphType;
+import dna.graph.datastructures.GraphDataStructure;
+import dna.graph.datastructures.IDataStructure;
+import dna.graph.datastructures.DataStructure.ListType;
+import dna.graph.edges.Edge;
+import dna.graph.nodes.Node;
+
+/**
+ * The Interface IGraph.
+ *
+ * @author Matthias
+ */
+public interface IGraph{
+
+ /**
+ * Adds the node.
+ *
+ * @param n the n
+ * @return true, if successful
+ */
+ public abstract boolean addNode(Node n);
+
+ /**
+ * Contains node.
+ *
+ * @param n the n
+ * @return true, if successful
+ */
+ public abstract boolean containsNode(Node n);
+
+ /**
+ * Retrieve a node by its index.
+ *
+ * @param index the index
+ * @return the node
+ */
+ public abstract Node getNode(int index);
+
+ /**
+ * Retrieve a random node.
+ *
+ * @return the random node
+ */
+ public abstract Node getRandomNode();
+
+ /**
+ * Retrieve a collection of all nodes within this graph.
+ *
+ * @return the nodes
+ */
+ public abstract Iterable getNodes();
+
+ /**
+ * Removes the node.
+ *
+ * @param n the node to be removed
+ * @return true, if successful
+ */
+ public abstract boolean removeNode(Node n);
+
+ /**
+ * Retrieve the highest node index within this graph.
+ *
+ * @return the max node index
+ */
+ public abstract int getMaxNodeIndex();
+
+ /**
+ * Retrieve the number of nodes within this graph.
+ *
+ * @return the node count
+ */
+ public abstract int getNodeCount();
+
+ /**
+ * Adds the edge.
+ *
+ * @param e the edge that should be added
+ * @return true, if successful
+ */
+ public abstract boolean addEdge(Edge e);
+
+ /**
+ * Contains edge.
+ *
+ * @param n1 the n1
+ * @param n2 the n2
+ * @return true, if successful
+ */
+ public abstract boolean containsEdge(Node n1, Node n2);
+
+ /**
+ * Contains edge.
+ *
+ * @param n1 the n1
+ * @param n2 the n2
+ * @return true, if successful
+ */
+ public abstract boolean containsEdge(int n1, int n2);
+
+ /**
+ * Contains edge.
+ *
+ * @param e the e
+ * @return true, if successful
+ */
+ public abstract boolean containsEdge(Edge e);
+
+ /**
+ * Contains nodes.
+ *
+ * @param e the e
+ * @return true, if successful
+ */
+ public abstract boolean containsNodes(Edge e);
+
+ /**
+ * Get an edge by its attached nodes.
+ *
+ * @param n1 the n1
+ * @param n2 the n2
+ * @return the edge
+ */
+ public abstract Edge getEdge(Node n1, Node n2);
+
+ /**
+ * Retrieve a random edge.
+ *
+ * @return the random edge
+ */
+ public abstract Edge getRandomEdge();
+
+ /**
+ * Retrieve a collection of all edges within this graph.
+ *
+ * @return the edges
+ */
+ public abstract Iterable getEdges();
+
+ /**
+ * Removes the edge.
+ *
+ * @param e the e
+ * @return true, if successful
+ */
+ public abstract boolean removeEdge(Edge e);
+
+ /**
+ * Retrieve the number of edges within this graph.
+ *
+ * @return the edge count
+ */
+ public abstract int getEdgeCount();
+
+ /**
+ * Check whether this is a directed graph or not.
+ *
+ * @return true, if the graph is directed; false otherwise
+ */
+ public abstract boolean isDirected();
+
+ /**
+ *
+ * i.e., V*(V-1) in case of a directed graph, V*(V-1)/2 in case of an
+ * undirected graph
+ *
+ * @return maximum number of edges the graph could have with the current
+ * number of nodes
+ */
+ public abstract BigInteger getMaxEdgeCount();
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public abstract void setName(String name);
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public abstract String getName();
+
+ /**
+ * Sets the timestamp.
+ *
+ * @param timestamp the new timestamp
+ */
+ public abstract void setTimestamp(long timestamp);
+
+ /**
+ * Gets the timestamp.
+ *
+ * @return the timestamp
+ */
+ public abstract long getTimestamp();
+
+ /**
+ * Gets the graph datastructures.
+ *
+ * @return the graph datastructures
+ */
+ public abstract GraphDataStructure getGraphDatastructures();
+
+ /**
+ * Equals.
+ *
+ * @param obj the obj
+ * @return true, if successful
+ */
+ public abstract boolean equals(Object obj);
+
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ public abstract String toString();
+
+ /**
+ * Prints the.
+ */
+ public abstract void print();
+
+ /**
+ * Prints the all.
+ */
+ public abstract void printAll();
+
+ /**
+ * Prints the v.
+ */
+ public abstract void printV();
+
+ /**
+ * Prints the e.
+ */
+ public abstract void printE();
+
+ /**
+ * Switch data structure.
+ *
+ * @param type the type
+ * @param newDatastructureType the new datastructure type
+ */
+ public abstract void switchDataStructure(ListType type,
+ Class extends IDataStructure> newDatastructureType);
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public abstract DNAGraphType getInstanceType();
+
+ /**
+ * release all resources.
+ */
+ public abstract void close();
+
+}
\ No newline at end of file
diff --git a/src/dna/graph/datastructures/GDS.java b/src/dna/graph/datastructures/GDS.java
index e691f7e7..5a3b1b3a 100644
--- a/src/dna/graph/datastructures/GDS.java
+++ b/src/dna/graph/datastructures/GDS.java
@@ -2,14 +2,22 @@
import dna.graph.datastructures.DataStructure.ListType;
import dna.graph.edges.DirectedEdge;
+import dna.graph.edges.DirectedBlueprintsEdge;
import dna.graph.edges.DirectedWeightedEdge;
+import dna.graph.edges.DirectedWeightedBlueprintsEdge;
import dna.graph.edges.Edge;
import dna.graph.edges.UndirectedEdge;
+import dna.graph.edges.UndirectedBlueprintsEdge;
import dna.graph.edges.UndirectedWeightedEdge;
+import dna.graph.edges.UndirectedWeightedBlueprintsEdge;
+import dna.graph.nodes.DirectedBlueprintsNode;
import dna.graph.nodes.DirectedNode;
+import dna.graph.nodes.DirectedWeightedBlueprintsNode;
import dna.graph.nodes.DirectedWeightedNode;
import dna.graph.nodes.Node;
+import dna.graph.nodes.UndirectedBlueprintsNode;
import dna.graph.nodes.UndirectedNode;
+import dna.graph.nodes.UndirectedWeightedBlueprintsNode;
import dna.graph.nodes.UndirectedWeightedNode;
import dna.graph.weights.Weight;
import dna.graph.weights.Weight.WeightSelection;
@@ -92,4 +100,48 @@ public static GraphDataStructure gds(Class extends Node> node,
ListType.LocalEdgeList, local), node, edge, nw, nws, ew, ews);
}
+ public static GraphDataStructure directedGDB() {
+ return gds(DirectedBlueprintsNode.class, DirectedBlueprintsEdge.class);
+ }
+
+ public static GraphDataStructure directedVGDB(Class extends Weight> nw,
+ WeightSelection nws) {
+ return gds(DirectedWeightedBlueprintsNode.class, DirectedBlueprintsEdge.class, nw,
+ nws, null, null);
+ }
+
+ public static GraphDataStructure directedEGDB(Class extends Weight> ew,
+ WeightSelection ews) {
+ return gds(DirectedBlueprintsNode.class, DirectedWeightedBlueprintsEdge.class, null, null, ew, ews);
+ }
+
+ public static GraphDataStructure directedVEGDB(Class extends Weight> nw,
+ WeightSelection nws, Class extends Weight> ew, WeightSelection ews) {
+ return gds(DirectedWeightedBlueprintsNode.class, DirectedWeightedBlueprintsEdge.class,
+ nw, nws, ew, ews);
+ }
+
+ public static GraphDataStructure undirectedGDB() {
+ return gds(UndirectedBlueprintsNode.class, UndirectedBlueprintsEdge.class);
+ }
+
+ public static GraphDataStructure undirectedVGDB(Class extends Weight> nw,
+ WeightSelection nws) {
+ return gds(UndirectedWeightedBlueprintsNode.class, UndirectedBlueprintsEdge.class,
+ nw, nws, null, null);
+ }
+
+ public static GraphDataStructure undirectedEGDB(Class extends Weight> ew,
+ WeightSelection ews) {
+ return gds(UndirectedBlueprintsNode.class, UndirectedWeightedBlueprintsEdge.class,
+ null, null, ew, ews);
+ }
+
+ public static GraphDataStructure undirectedVEGDB(
+ Class extends Weight> nw, WeightSelection nws,
+ Class extends Weight> ew, WeightSelection ews) {
+ return gds(UndirectedWeightedBlueprintsNode.class,
+ UndirectedWeightedBlueprintsEdge.class, nw, nws, ew, ews);
+ }
+
}
diff --git a/src/dna/graph/datastructures/GraphDataStructure.java b/src/dna/graph/datastructures/GraphDataStructure.java
index cd04e093..b18c3024 100644
--- a/src/dna/graph/datastructures/GraphDataStructure.java
+++ b/src/dna/graph/datastructures/GraphDataStructure.java
@@ -9,17 +9,25 @@
import java.util.Map.Entry;
import dna.graph.ClassPointers;
-import dna.graph.Graph;
+import dna.graph.DNAGraphFactory;
+import dna.graph.DNAGraphFactory.DNAGraphType;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.datastructures.DataStructure.ListType;
+import dna.graph.edges.DirectedBlueprintsEdge;
import dna.graph.edges.DirectedEdge;
+import dna.graph.edges.DummyDirectedBlueprintsEdge;
import dna.graph.edges.DummyDirectedEdge;
+import dna.graph.edges.DummyUndirectedBlueprintsEdge;
import dna.graph.edges.DummyUndirectedEdge;
import dna.graph.edges.Edge;
import dna.graph.edges.IEdgeDummy;
+import dna.graph.edges.UndirectedBlueprintsEdge;
import dna.graph.edges.UndirectedEdge;
+import dna.graph.nodes.DirectedBlueprintsNode;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.Node;
+import dna.graph.nodes.UndirectedBlueprintsNode;
import dna.graph.nodes.UndirectedNode;
import dna.graph.weights.IWeighted;
import dna.graph.weights.Weight;
@@ -299,8 +307,14 @@ public void setEdgeType(Class extends Edge> edgeType) {
this.edgeType = edgeType;
}
- public Graph newGraphInstance(String name, long timestamp, int nodes,
+ public IGraph newGraphInstance(String name, long timestamp, int nodes,
int edges) {
+ setCurrent(this);
+
+ if (this.usesGraphDatabase())
+ return DNAGraphFactory.newGraphInstance(DNAGraphType.CONFIG, name, timestamp,
+ this, nodes, edges);
+
this.canGDSCreateProperLists();
this.defaultListSizes.put(ListType.GlobalNodeList, nodes);
this.defaultListSizes.put(ListType.GlobalEdgeList, edges);
@@ -317,10 +331,31 @@ public Graph newGraphInstance(String name, long timestamp, int nodes,
}
setCurrent(this);
-
- return new Graph(name, timestamp, this, nodes, edges);
+
+ return DNAGraphFactory.newGraphInstance(DNAGraphType.DNA, name, timestamp, this, nodes, edges);
}
-
+
+ public IGraph newGraphInstanceOfType(String name, long timestamp, DNAGraphType type) {
+ setCurrent(this);
+ return DNAGraphFactory.newGraphInstance(type, name, timestamp, this);
+ }
+
+ public IGraph newGraphInstanceOfType(String name, long timestamp, DNAGraphType type,
+ int operationsPerCommit, boolean clearWorkSpace, String workspaceDir,
+ boolean storeDNAElementsInGDB) {
+ setCurrent(this);
+ return DNAGraphFactory.newGraphInstance(type, name, timestamp, this, operationsPerCommit,
+ clearWorkSpace, workspaceDir, storeDNAElementsInGDB);
+ }
+
+ public IGraph newGraphInstanceOfType(String name, long timestamp, int nodes, int edges,
+ DNAGraphType type, int operationsPerCommit, boolean clearWorkSpace, String workspaceDir ,
+ boolean storeDNAElementsInGDB) {
+ setCurrent(this);
+ return DNAGraphFactory.newGraphInstance(type, name, timestamp, this, nodes, edges, operationsPerCommit,
+ clearWorkSpace, workspaceDir, storeDNAElementsInGDB);
+ }
+
private int getStartingSize(ListType lt) {
if (overrideDefaultListSizes.containsKey(lt)) {
return overrideDefaultListSizes.get(lt);
@@ -522,11 +557,11 @@ public Edge newEdgeInstance(Node src, Node dst) {
}
}
- public Edge newEdgeInstance(String str, Graph graph,
+ public Edge newEdgeInstance(String str, IGraph graph,
HashMap addedNodes) {
Constructor extends Edge> c;
try {
- c = edgeType.getConstructor(String.class, Graph.class,
+ c = edgeType.getConstructor(String.class, IGraph.class,
HashMap.class);
return c.newInstance(str, graph, addedNodes);
} catch (InvocationTargetException ite) {
@@ -543,10 +578,10 @@ public Edge newEdgeInstance(String str, Graph graph,
}
}
- public Edge newEdgeInstance(String str, Graph graph) {
+ public Edge newEdgeInstance(String str, IGraph graph) {
Constructor extends Edge> c;
try {
- c = edgeType.getConstructor(String.class, Graph.class);
+ c = edgeType.getConstructor(String.class, IGraph.class);
return c.newInstance(str, graph);
} catch (InvocationTargetException ite) {
RuntimeException rt = new RuntimeException(
@@ -563,7 +598,13 @@ public Edge newEdgeInstance(String str, Graph graph) {
}
public Edge getDummyEdge(Node n1, Node n2) {
- return getDummyEdge(n1.getIndex(), n2.getIndex());
+ if ((n1.getClass().equals(DirectedBlueprintsNode.class) && n2.getClass().equals(DirectedBlueprintsNode.class))
+ || (n1.getClass().equals(UndirectedBlueprintsNode.class) && n2.getClass().equals(UndirectedBlueprintsNode.class)))
+ {
+ return getDummyGDBEdge(n1.getIndex(), n2.getIndex());
+ }
+ else
+ return getDummyEdge(n1.getIndex(), n2.getIndex());
}
public Edge getDummyEdge(int n1, int n2) {
@@ -581,6 +622,22 @@ public Edge getDummyEdge(int n1, int n2) {
edgeDummy.setNodes(n1, n2);
return (Edge) edgeDummy;
}
+
+ public Edge getDummyGDBEdge(int n1, int n2) {
+ if (edgeDummy == null) {
+ if (createsDirected()) {
+ DirectedBlueprintsNode node1 = new DirectedBlueprintsNode(1, this);
+ DirectedBlueprintsNode node2 = new DirectedBlueprintsNode(2, this);
+ edgeDummy = new DummyDirectedBlueprintsEdge(node1, node2);
+ } else {
+ UndirectedBlueprintsNode node1 = new UndirectedBlueprintsNode(1, this);
+ UndirectedBlueprintsNode node2 = new UndirectedBlueprintsNode(2, this);
+ edgeDummy = new DummyUndirectedBlueprintsEdge(node1, node2);
+ }
+ }
+ edgeDummy.setNodes(n1, n2);
+ return (Edge) edgeDummy;
+ }
public Constructor> getConstructor(Constructor>[] list,
Class>[] required) {
@@ -742,12 +799,20 @@ public boolean createsWeightedEdges() {
return IWeighted.class.isAssignableFrom(edgeType);
}
+ public boolean usesGraphDatabase()
+ {
+ return DirectedBlueprintsNode.class.isAssignableFrom(nodeType)
+ || UndirectedBlueprintsNode.class.isAssignableFrom(nodeType);
+ }
+
public boolean createsDirected() {
- return DirectedEdge.class.isAssignableFrom(edgeType);
+ return DirectedEdge.class.isAssignableFrom(edgeType)
+ || DirectedBlueprintsEdge.class.isAssignableFrom(edgeType);
}
-
+
public boolean createsUndirected() {
- return UndirectedEdge.class.isAssignableFrom(edgeType);
+ return UndirectedEdge.class.isAssignableFrom(edgeType)
+ || UndirectedBlueprintsEdge.class.isAssignableFrom(edgeType);
}
public EnumMap> getStorageDataStructures() {
@@ -837,7 +902,7 @@ public boolean isReadable(Class extends IDataStructure> list) {
* @param newGDS
* @param g
*/
- public void switchDatastructures(GraphDataStructure newGDS, Graph g) {
+ public void switchDatastructures(GraphDataStructure newGDS, IGraph g) {
if (!this.isReadable(getListClass(ListType.GlobalEdgeList))) {
System.err
.println("Reject switching data structures, as graph edge list of type "
diff --git a/src/dna/graph/datastructures/cost/RuntimeMeasurement.java b/src/dna/graph/datastructures/cost/RuntimeMeasurement.java
index 6e0466c4..ef7d6f18 100644
--- a/src/dna/graph/datastructures/cost/RuntimeMeasurement.java
+++ b/src/dna/graph/datastructures/cost/RuntimeMeasurement.java
@@ -8,7 +8,7 @@
import java.util.LinkedList;
import java.util.Random;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.datastructures.DataStructure.ListType;
import dna.graph.datastructures.GDS;
@@ -255,7 +255,7 @@ protected Node[] getNodesToAdd() {
GraphGenerator gg = new RandomGraph(getGDS(this.dt), (this.steps + 1)
* this.stepSize, 0);
Counting.init(gg.getGds());
- Graph g = gg.generate();
+ IGraph g = gg.generate();
Node[] nodes = new Node[g.getNodeCount()];
int index = 0;
for (IElement n_ : g.getNodes()) {
@@ -269,7 +269,7 @@ protected Edge[] getEdgesToAdd() {
* Math.max(this.stepSize / 10, 1), (this.steps + 1)
* this.stepSize);
Counting.init(gg.getGds());
- Graph g = gg.generate();
+ IGraph g = gg.generate();
Edge[] edges = new Edge[g.getEdgeCount()];
int index = 0;
for (IElement e_ : g.getEdges()) {
diff --git a/src/dna/graph/datastructures/count/Counting.java b/src/dna/graph/datastructures/count/Counting.java
index d26757ac..97307cb5 100644
--- a/src/dna/graph/datastructures/count/Counting.java
+++ b/src/dna/graph/datastructures/count/Counting.java
@@ -3,7 +3,7 @@
import java.util.LinkedList;
import java.util.ListIterator;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.count.OperationCount.AggregationType;
import dna.graph.edges.DirectedEdge;
@@ -31,7 +31,7 @@ protected static void initOC() {
}
}
- public static void setSizes(Graph g) {
+ public static void setSizes(IGraph g) {
Counting.oc.setSizes(g);
}
@@ -74,25 +74,25 @@ public static void startRun() {
initOC();
}
- public static void endGraphGeneration(Graph g) {
+ public static void endGraphGeneration(IGraph g) {
graphGeneration = oc;
setSizes(g);
initOC();
}
- public static void endMetricInit(Graph g) {
+ public static void endMetricInit(IGraph g) {
metricInit = oc;
setSizes(g);
initOC();
}
- public static void endBatchGeneration(Graph g) {
+ public static void endBatchGeneration(IGraph g) {
batchGeneration.add(oc);
setSizes(g);
initOC();
}
- public static void endBatchApplication(Graph g) {
+ public static void endBatchApplication(IGraph g) {
batchApplication.add(oc);
setSizes(g);
initOC();
diff --git a/src/dna/graph/datastructures/count/CountingAspects.aj b/src/dna/graph/datastructures/count/CountingAspects.aj
index cb7d410b..4b431b27 100644
--- a/src/dna/graph/datastructures/count/CountingAspects.aj
+++ b/src/dna/graph/datastructures/count/CountingAspects.aj
@@ -2,7 +2,7 @@ package dna.graph.datastructures.count;
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.generators.GraphGenerator;
import dna.metrics.algorithms.Algorithms;
import dna.series.Series;
@@ -38,8 +38,8 @@ public aspect CountingAspects {
call(* GraphGenerator.generate()) &&
cflow(call(BatchData SeriesGeneration.computeInitialData(Series, Algorithms)) && args(s,a));
- Graph around(GraphGenerator gg, Series s, Algorithms a) : graphGeneration_NEW(gg, s, a) {
- Graph g = proceed(gg, s, a);
+ IGraph around(GraphGenerator gg, Series s, Algorithms a) : graphGeneration_NEW(gg, s, a) {
+ IGraph g = proceed(gg, s, a);
Counting.endGraphGeneration(g);
return g;
}
@@ -55,13 +55,13 @@ public aspect CountingAspects {
return res;
}
- pointcut batchGeneration(Graph g, Series s, Algorithms a) :
+ pointcut batchGeneration(IGraph g, Series s, Algorithms a) :
if(Counting.isEnabled()) &&
args(g) &&
call(* BatchGenerator.generate(Graph)) &&
cflow(call(* SeriesGeneration.computeNextBatch(Series, Algorithms)) && args(s, a));
- Batch around(Graph g, Series s, Algorithms a) : batchGeneration(g, s, a) {
+ Batch around(IGraph g, Series s, Algorithms a) : batchGeneration(g, s, a) {
Batch res = proceed(g, s, a);
Counting.endBatchGeneration(g);
return res;
diff --git a/src/dna/graph/datastructures/count/OperationCounts.java b/src/dna/graph/datastructures/count/OperationCounts.java
index 57bc3a38..d903f7df 100644
--- a/src/dna/graph/datastructures/count/OperationCounts.java
+++ b/src/dna/graph/datastructures/count/OperationCounts.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.DataStructure.ListType;
import dna.graph.datastructures.count.OperationCount.AggregationType;
import dna.util.Config;
@@ -39,7 +39,7 @@ public abstract void writeValues(String dir, String filename)
public abstract void readValues(String dir, String filename)
throws IOException;
- public abstract void setSizes(Graph g);
+ public abstract void setSizes(IGraph g);
public abstract OperationCounts add(AggregationType at, OperationCounts... ocs);
}
diff --git a/src/dna/graph/datastructures/count/OperationCountsDirected.java b/src/dna/graph/datastructures/count/OperationCountsDirected.java
index bad30444..4306763f 100644
--- a/src/dna/graph/datastructures/count/OperationCountsDirected.java
+++ b/src/dna/graph/datastructures/count/OperationCountsDirected.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.DataStructure.ListType;
import dna.graph.datastructures.count.OperationCount.AggregationType;
import dna.io.Reader;
@@ -86,7 +86,7 @@ public void readValues(String dir, String filename) throws IOException {
}
@Override
- public void setSizes(Graph g) {
+ public void setSizes(IGraph g) {
int nodes = g.getNodeCount();
int edges = g.getEdgeCount();
diff --git a/src/dna/graph/datastructures/count/OperationCountsUndirected.java b/src/dna/graph/datastructures/count/OperationCountsUndirected.java
index 2b12727d..289ec4fe 100644
--- a/src/dna/graph/datastructures/count/OperationCountsUndirected.java
+++ b/src/dna/graph/datastructures/count/OperationCountsUndirected.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.DataStructure.ListType;
import dna.graph.datastructures.count.OperationCount.AggregationType;
import dna.io.Reader;
@@ -70,7 +70,7 @@ public void readValues(String dir, String filename) throws IOException {
}
@Override
- public void setSizes(Graph g) {
+ public void setSizes(IGraph g) {
int nodes = g.getNodeCount();
int edges = g.getEdgeCount();
diff --git a/src/dna/graph/datastructures/hotswap/Hotswap.java b/src/dna/graph/datastructures/hotswap/Hotswap.java
index c8a807bf..418a0ece 100644
--- a/src/dna/graph/datastructures/hotswap/Hotswap.java
+++ b/src/dna/graph/datastructures/hotswap/Hotswap.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.DArray;
import dna.graph.datastructures.DArrayList;
import dna.graph.datastructures.DHashMap;
@@ -87,7 +87,7 @@ public static DSConfig recommendConfig(OperationCounts ocs,
return r.recommendFastestConfig(ocs, batches, amortization, current);
}
- public static boolean execute(Graph g, OperationCounts ocs, DSConfig current, DSConfig cfg) {
+ public static boolean execute(IGraph g, OperationCounts ocs, DSConfig current, DSConfig cfg) {
// System.out.println("HOTSWAP - EXECUTE");
double costCurrent = CostEstimation.estimateCosts(current, ocs, r.map);
double costRecommendation = CostEstimation.estimateCosts(cfg, ocs,
@@ -140,7 +140,7 @@ public static void testStatic(int batches, DSConfig current) {
+ (cost / costCurrent));
}
- public static void execute(Graph g, DSConfigDirected current,
+ public static void execute(IGraph g, DSConfigDirected current,
DSConfigDirected cfg) {
System.out.println("HOTSWAP EXECUTE directed");
if (!current.V.equals(cfg.V)) {
@@ -160,7 +160,7 @@ public static void execute(Graph g, DSConfigDirected current,
}
}
- public static void execute(Graph g, DSConfigUndirected current,
+ public static void execute(IGraph g, DSConfigUndirected current,
DSConfigUndirected cfg) {
System.out.println("HOTSWAP EXECUTE undirected");
if (!current.V.equals(cfg.V)) {
@@ -174,27 +174,27 @@ public static void execute(Graph g, DSConfigUndirected current,
}
}
- protected static void swapV(Graph g, Class ds) {
+ protected static void swapV(IGraph g, Class ds) {
}
- protected static void swapE(Graph g, Class ds) {
+ protected static void swapE(IGraph g, Class ds) {
}
- protected static void swapAdj(Graph g, Class ds) {
+ protected static void swapAdj(IGraph g, Class ds) {
}
- protected static void swapIn(Graph g, Class ds) {
+ protected static void swapIn(IGraph g, Class ds) {
}
- protected static void swapOut(Graph g, Class ds) {
+ protected static void swapOut(IGraph g, Class ds) {
}
- protected static void swapNeighbors(Graph g, Class ds) {
+ protected static void swapNeighbors(IGraph g, Class ds) {
}
diff --git a/src/dna/graph/edges/DirectedBlueprintsEdge.java b/src/dna/graph/edges/DirectedBlueprintsEdge.java
new file mode 100644
index 00000000..c74ee111
--- /dev/null
+++ b/src/dna/graph/edges/DirectedBlueprintsEdge.java
@@ -0,0 +1,209 @@
+package dna.graph.edges;
+
+import java.util.HashMap;
+
+import com.tinkerpop.blueprints.Edge;
+
+import dna.graph.BlueprintsGraph;
+import dna.graph.IGraph;
+import dna.graph.nodes.DirectedNode;
+import dna.graph.nodes.DirectedBlueprintsNode;
+import dna.graph.nodes.Node;
+import dna.util.MathHelper;
+
+/**
+ * The Class DirectedBlueprintsEdge.
+ *
+ * @author Matthias
+ */
+public class DirectedBlueprintsEdge extends DirectedEdge implements IGDBEdge {
+
+ /** The edge identifier. */
+ protected Object gdbEdgeId;
+
+ /** The graph. */
+ protected BlueprintsGraph graph;
+
+ /**
+ * Instantiates a new directed blueprints edge.
+ *
+ * @param src the source node
+ * @param dst the destination node
+ */
+ public DirectedBlueprintsEdge(DirectedBlueprintsNode src, DirectedBlueprintsNode dst) {
+ super(src, dst);
+ }
+
+ /**
+ * Instantiates a new directed blueprints edge.
+ *
+ * @param src the source node
+ * @param dst the destination node
+ * @param e the graph database edge
+ */
+ public DirectedBlueprintsEdge(DirectedBlueprintsNode src, DirectedBlueprintsNode dst,
+ Object gdbEdgeId) {
+ super(src, dst);
+ this.setGDBEdgeId(this.gdbEdgeId);
+ }
+
+ /**
+ * Instantiates a new directed blueprints edge.
+ *
+ * @param s the string
+ * @param g the graph
+ */
+ public DirectedBlueprintsEdge(String s, IGraph g) {
+ super((DirectedNode) getNodeFromStr(0, s, g),
+ (DirectedNode) getNodeFromStr(1, s, g));
+ this.setGraph(g);
+ }
+
+ /**
+ * Instantiates a new directed blueprints edge.
+ *
+ * @param s the string
+ * @param g the graph
+ * @param addedNodes the added nodes
+ */
+ public DirectedBlueprintsEdge(String s, IGraph g, HashMap addedNodes) {
+ super((DirectedNode) getNodeFromStr(0, s, g, addedNodes)
+ , (DirectedNode) getNodeFromStr(1, s, g, addedNodes));
+ this.setGraph(g);
+ }
+
+ /**
+ * Gets the node from the string.
+ *
+ * @param index the index
+ * @param s the string
+ * @param g the graph
+ * @return the node from the string
+ */
+ private static Node getNodeFromStr(int index, String s, IGraph g) {
+ if (index < 0 || index > 1) {
+ throw new IndexOutOfBoundsException(
+ "The index must be 0 or 1, but was " + index + ".");
+ }
+
+ String[] temp = s.split(DirectedEdge.separator);
+ if (temp.length != 2) {
+ throw new IllegalArgumentException("Cannot parse " + s
+ + " into a directed edge");
+ }
+ return (DirectedBlueprintsNode) g.getNode(MathHelper
+ .parseInt(temp[index]));
+ }
+
+ /**
+ * Gets the node from str.
+ *
+ * @param index the index
+ * @param s the string
+ * @param g the graph
+ * @param addedNodes the added nodes
+ * @return the node from str
+ */
+ private static Node getNodeFromStr(int index, String s, IGraph g,
+ HashMap addedNodes) {
+ if (index < 0 || index > 1) {
+ throw new IndexOutOfBoundsException(
+ "The index must be 0 or 1, but was " + index + ".");
+ }
+
+ String[] temp = s.split(DirectedBlueprintsEdge.separator);
+ if (temp.length != 2) {
+ throw new IllegalArgumentException("Cannot parse " + s
+ + " into a directed edge");
+ }
+
+ int idx = MathHelper.parseInt(temp[index]);
+ if (addedNodes.containsKey(idx)) {
+ return (DirectedBlueprintsNode) addedNodes.get(idx);
+ } else {
+ return (DirectedBlueprintsNode) g.getNode(idx);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.DirectedEdge#connectToNodes()
+ */
+ @Override
+ public boolean connectToNodes() {
+ if (this.getSrc().hasEdge(this) && this.getDst().hasEdge(this))
+ return true;
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.DirectedEdge#disconnectFromNodes()
+ */
+ @Override
+ public boolean disconnectFromNodes() {
+ if (!this.getSrc().hasEdge(this) && !this.getDst().hasEdge(this))
+ return true;
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.DirectedEdge#getDst()
+ */
+ @Override
+ public DirectedBlueprintsNode getDst() {
+ return (DirectedBlueprintsNode) getN2();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.edges.IGDBEdge#getEdge()
+ */
+ @Override
+ public Edge getGDBEdge() {
+ if (this.graph == null || this.gdbEdgeId == null)
+ return null;
+ else
+ return this.graph.getGDBEdge(this.gdbEdgeId);
+ }
+
+ @Override
+ public Object getGDBEdgeId() {
+ return this.gdbEdgeId;
+ }
+
+ @Override
+ public IGraph getGraph() {
+ return this.graph;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.DirectedEdge#getSrc()
+ */
+ //
+ @Override
+ public DirectedBlueprintsNode getSrc() {
+ return (DirectedBlueprintsNode) getN1();
+ }
+
+ @Override
+ public void setGDBEdgeId(Object gdbEdgeId) {
+ this.gdbEdgeId = gdbEdgeId;
+ }
+
+ @Override
+ public void setGraph(IGraph graph) {
+ if (graph instanceof BlueprintsGraph)
+ this.graph = (BlueprintsGraph) graph;
+ else
+ throw new RuntimeException("The parameter 'graph' must be an instance of " + BlueprintsGraph.class
+ + "but was " + graph.getClass());
+ }
+
+ @Override
+ public String toString()
+ {
+ return this.getN1().getIndex() + " " + separator + " " + this.getN2().getIndex();
+ }
+}
diff --git a/src/dna/graph/edges/DirectedEdge.java b/src/dna/graph/edges/DirectedEdge.java
index 84cb5fb4..feb92d71 100644
--- a/src/dna/graph/edges/DirectedEdge.java
+++ b/src/dna/graph/edges/DirectedEdge.java
@@ -3,7 +3,7 @@
import java.util.HashMap;
import dna.graph.Element;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.Node;
import dna.util.MathHelper;
@@ -16,7 +16,7 @@ public DirectedEdge(DirectedNode src, DirectedNode dst) {
init(src, dst);
}
- public DirectedEdge(String s, Graph g) {
+ public DirectedEdge(String s, IGraph g) {
String[] temp = s.split(DirectedEdge.separator);
if (temp.length != 2) {
throw new IllegalArgumentException("Cannot parse " + s
@@ -29,7 +29,7 @@ public DirectedEdge(String s, Graph g) {
init(src, dst);
}
- public DirectedEdge(String s, Graph g, HashMap addedNodes) {
+ public DirectedEdge(String s, IGraph g, HashMap addedNodes) {
String[] temp = s.split(DirectedEdge.separator);
if (temp.length != 2) {
throw new IllegalArgumentException("Cannot parse " + s
diff --git a/src/dna/graph/edges/DirectedWeightedBlueprintsEdge.java b/src/dna/graph/edges/DirectedWeightedBlueprintsEdge.java
new file mode 100644
index 00000000..8d5665d9
--- /dev/null
+++ b/src/dna/graph/edges/DirectedWeightedBlueprintsEdge.java
@@ -0,0 +1,114 @@
+package dna.graph.edges;
+
+import java.util.HashMap;
+import dna.graph.IGraph;
+import dna.graph.nodes.DirectedBlueprintsNode;
+import dna.graph.nodes.Node;
+import dna.graph.weights.IWeightedEdge;
+import dna.graph.weights.Weight;
+
+/**
+ * The Class DirectedWeightedBlueprintsEdge.
+ *
+ * @author Matthias
+ */
+public class DirectedWeightedBlueprintsEdge extends DirectedBlueprintsEdge implements IWeightedEdge {
+
+ /** The weight. */
+ protected Weight weight;
+
+ /**
+ * Instantiates a new directed weighted blueprints edge.
+ *
+ * @param src the src
+ * @param dst the dst
+ * @param weight the weight
+ */
+ public DirectedWeightedBlueprintsEdge(DirectedBlueprintsNode src, DirectedBlueprintsNode dst,
+ Weight weight) {
+ super(src, dst);
+ this.setWeight(weight);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints edge.
+ *
+ * @param s the s
+ * @param g the g
+ */
+ public DirectedWeightedBlueprintsEdge(String s, IGraph g) {
+ super(s.split(Weight.WeightDelimiter)[0], g);
+ this.weight = g.getGraphDatastructures().newEdgeWeight(
+ s.split(Weight.WeightDelimiter)[1]);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints edge.
+ *
+ * @param s the s
+ * @param g the g
+ * @param addedNodes the added nodes
+ */
+ public DirectedWeightedBlueprintsEdge(String s, IGraph g,
+ HashMap addedNodes) {
+ super(s.split(Weight.WeightDelimiter)[0], g, addedNodes);
+ this.weight = g.getGraphDatastructures().newEdgeWeight(
+ s.split(Weight.WeightDelimiter)[1]);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints edge.
+ *
+ * @param src the src
+ * @param dst the dst
+ * @param weight the weight
+ * @param e the e
+ */
+ public DirectedWeightedBlueprintsEdge(DirectedBlueprintsNode src, DirectedBlueprintsNode dst,
+ Weight weight, Object gdbEdgeId) {
+ super(src, dst);
+ this.setGDBEdgeId(gdbEdgeId);
+ this.setWeight(weight);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#getWeight()
+ */
+ @Override
+ public Weight getWeight() {
+ if (this.getGDBEdge() == null)
+ return this.weight;
+
+ String weight = this.getGDBEdge().getProperty("weight");
+ if (weight == null)
+ this.setWeight(this.weight);
+ return this.weight;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#setWeight(dna.graph.weights.Weight)
+ */
+ @Override
+ public void setWeight(Weight weight) {
+ this.weight = weight;
+ if (this.getGDBEdge() == null)
+ return;
+ this.getGDBEdge().setProperty("weight", weight.asString());
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.DirectedEdge#asString()
+ */
+ @Override
+ public String asString() {
+ return super.asString() + Weight.WeightDelimiter
+ + this.weight.asString();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.DirectedEdge#toString()
+ */
+ public String toString() {
+ return super.toString() + " [" + this.getWeight().asString() + "]";
+ }
+}
diff --git a/src/dna/graph/edges/DirectedWeightedEdge.java b/src/dna/graph/edges/DirectedWeightedEdge.java
index a341eb06..bc375cba 100644
--- a/src/dna/graph/edges/DirectedWeightedEdge.java
+++ b/src/dna/graph/edges/DirectedWeightedEdge.java
@@ -2,7 +2,7 @@
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.Node;
import dna.graph.weights.IWeightedEdge;
@@ -18,13 +18,13 @@ public DirectedWeightedEdge(DirectedNode src, DirectedNode dst,
this.weight = weight;
}
- public DirectedWeightedEdge(String s, Graph g) {
+ public DirectedWeightedEdge(String s, IGraph g) {
super(s.split(Weight.WeightDelimiter)[0], g);
this.weight = g.getGraphDatastructures().newEdgeWeight(
s.split(Weight.WeightDelimiter)[1]);
}
- public DirectedWeightedEdge(String s, Graph g,
+ public DirectedWeightedEdge(String s, IGraph g,
HashMap addedNodes) {
super(s.split(Weight.WeightDelimiter)[0], g, addedNodes);
this.weight = g.getGraphDatastructures().newEdgeWeight(
diff --git a/src/dna/graph/edges/DummyDirectedBlueprintsEdge.java b/src/dna/graph/edges/DummyDirectedBlueprintsEdge.java
new file mode 100644
index 00000000..cecb1365
--- /dev/null
+++ b/src/dna/graph/edges/DummyDirectedBlueprintsEdge.java
@@ -0,0 +1,15 @@
+package dna.graph.edges;
+
+import dna.graph.nodes.DirectedBlueprintsNode;
+
+public class DummyDirectedBlueprintsEdge extends DirectedBlueprintsEdge implements IEdgeDummy {
+
+ public DummyDirectedBlueprintsEdge(DirectedBlueprintsNode src, DirectedBlueprintsNode dst) {
+ super(src, dst);
+ }
+
+ public void setNodes(int n1, int n2) {
+ this.n1.setIndex(n1);
+ this.n2.setIndex(n2);
+ }
+}
diff --git a/src/dna/graph/edges/DummyUndirectedBlueprintsEdge.java b/src/dna/graph/edges/DummyUndirectedBlueprintsEdge.java
new file mode 100644
index 00000000..663e5ce6
--- /dev/null
+++ b/src/dna/graph/edges/DummyUndirectedBlueprintsEdge.java
@@ -0,0 +1,15 @@
+package dna.graph.edges;
+
+import dna.graph.nodes.UndirectedBlueprintsNode;
+
+public class DummyUndirectedBlueprintsEdge extends UndirectedBlueprintsEdge implements IEdgeDummy {
+
+ public DummyUndirectedBlueprintsEdge(UndirectedBlueprintsNode src, UndirectedBlueprintsNode dst) {
+ super(src, dst);
+ }
+
+ public void setNodes(int n1, int n2) {
+ this.n1.setIndex(Math.min(n1, n2));
+ this.n2.setIndex(Math.max(n1, n2));
+ }
+}
diff --git a/src/dna/graph/edges/IGDBEdge.java b/src/dna/graph/edges/IGDBEdge.java
new file mode 100644
index 00000000..fff805a7
--- /dev/null
+++ b/src/dna/graph/edges/IGDBEdge.java
@@ -0,0 +1,17 @@
+package dna.graph.edges;
+
+import dna.graph.IGraph;
+
+public interface IGDBEdge {
+
+ public abstract void setGraph(IGraph graph);
+
+ public abstract IGraph getGraph();
+
+ public abstract void setGDBEdgeId(Object gdbEdgeId);
+
+ public abstract Object getGDBEdgeId();
+
+ public abstract E getGDBEdge();
+
+}
\ No newline at end of file
diff --git a/src/dna/graph/edges/UndirectedBlueprintsEdge.java b/src/dna/graph/edges/UndirectedBlueprintsEdge.java
new file mode 100644
index 00000000..f6897e8f
--- /dev/null
+++ b/src/dna/graph/edges/UndirectedBlueprintsEdge.java
@@ -0,0 +1,221 @@
+package dna.graph.edges;
+
+import java.util.HashMap;
+
+import com.tinkerpop.blueprints.Edge;
+
+import dna.graph.edges.UndirectedEdge;
+import dna.graph.nodes.Node;
+import dna.graph.nodes.UndirectedBlueprintsNode;
+import dna.graph.nodes.UndirectedNode;
+import dna.graph.BlueprintsGraph;
+import dna.graph.IGraph;
+import dna.updates.update.Update;
+import dna.util.MathHelper;
+
+/**
+ * The Class UndirectedBlueprintsEdge.
+ *
+ * @author Matthias
+ */
+public class UndirectedBlueprintsEdge extends UndirectedEdge implements IGDBEdge {
+
+ /** The edge identifier. */
+ protected Object gdbEdgeId;
+
+ /** The graph. */
+ protected BlueprintsGraph graph;
+
+ /**
+ * Instantiates a new undirected blueprints edge.
+ *
+ * @param s String representation of an undirected edge
+ * @param g graph this undirected edge is belonging to (required to obtain
+ * node object pointers)
+ */
+ public UndirectedBlueprintsEdge(String s, IGraph g) {
+ super((UndirectedNode) getNodeFromStr(0, s, g),
+ (UndirectedNode) getNodeFromStr(1, s, g));
+ }
+
+ /**
+ * Instantiates a new undirected blueprints edge.
+ *
+ * @param s the s
+ * @param g the g
+ * @param addedNodes the added nodes
+ */
+ public UndirectedBlueprintsEdge(String s, IGraph g,
+ HashMap addedNodes) {
+ super((UndirectedNode) getNodeFromStr(0, s, g, addedNodes),
+ (UndirectedNode) getNodeFromStr(1, s, g, addedNodes));
+ }
+
+ /**
+ *
+ * The node with the lower index is stored as the first node. In case
+ * node1.index > node2.index, they are stored in changed order.
+ *
+ * @param node1
+ * first node connected by this edge
+ * @param node2
+ * second node connected by this edge
+ */
+ public UndirectedBlueprintsEdge(UndirectedBlueprintsNode node1, UndirectedBlueprintsNode node2) {
+ super(node1, node2);
+ }
+
+ /**
+ * Instantiates a new undirected blueprints edge.
+ *
+ * @param src the src
+ * @param dst the dst
+ * @param e the e
+ */
+ public UndirectedBlueprintsEdge(UndirectedBlueprintsNode src, UndirectedBlueprintsNode dst,
+ Object gdbEdgeId) {
+ super(src, dst);
+ this.setGDBEdgeId(gdbEdgeId);
+ }
+
+ /**
+ * Gets the node from str.
+ *
+ * @param index the index
+ * @param s the s
+ * @param g the g
+ * @return the node from str
+ */
+ private static Node getNodeFromStr(int index, String s, IGraph g) {
+ if (index < 0 || index > 1) {
+ throw new IndexOutOfBoundsException(
+ "The index must be 0 or 1, but was " + index + ".");
+ }
+
+ String[] temp = s.contains(UndirectedBlueprintsEdge.separator) ? s
+ .split(UndirectedBlueprintsEdge.separator) : s
+ .split(Update.EdgeSeparator);
+ if (temp.length != 2) {
+ throw new IllegalArgumentException("Cannot parse " + s
+ + " into an undirected edge");
+ }
+
+ return (UndirectedBlueprintsNode) g.getNode(MathHelper.parseInt(temp[index]));
+ }
+
+ /**
+ * Gets the node from str.
+ *
+ * @param index the index
+ * @param s the s
+ * @param g the g
+ * @param addedNodes the added nodes
+ * @return the node from str
+ */
+ private static Node getNodeFromStr(int index, String s, IGraph g,
+ HashMap addedNodes) {
+ if (index < 0 || index > 1) {
+ throw new IndexOutOfBoundsException(
+ "The index must be 0 or 1, but was " + index + ".");
+ }
+
+ String[] temp = s.contains(UndirectedBlueprintsEdge.separator) ? s
+ .split(UndirectedBlueprintsEdge.separator) : s
+ .split(Update.EdgeSeparator);
+ if (temp.length != 2) {
+ throw new IllegalArgumentException("Cannot parse " + s
+ + " into an undirected edge");
+ }
+
+ int idx = MathHelper.parseInt(temp[index]);
+ if (addedNodes.containsKey(idx)) {
+ return (UndirectedNode) addedNodes.get(idx);
+ } else {
+ return (UndirectedNode) g.getNode(idx);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.UndirectedEdge#connectToNodes()
+ */
+ @Override
+ public boolean connectToNodes() {
+ if (this.getNode1().hasEdge(this) && this.getNode2().hasEdge(this))
+ return true;
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.UndirectedEdge#disconnectFromNodes()
+ */
+ @Override
+ public boolean disconnectFromNodes() {
+ if (!this.getNode1().hasEdge(this) && !this.getNode2().hasEdge(this))
+ return true;
+
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.edges.IGDBEdge#getEdge()
+ */
+ @Override
+ public Edge getGDBEdge() {
+ if (this.graph == null || this.gdbEdgeId == null)
+ return null;
+ else
+ return this.graph.getGDBEdge(this.gdbEdgeId);
+ }
+
+ @Override
+ public Object getGDBEdgeId() {
+ return this.gdbEdgeId;
+ }
+
+ @Override
+ public IGraph getGraph() {
+ return this.graph;
+ }
+
+ /**
+ * Gets the node1.
+ *
+ * @return first node connected by this edge (the node with the lower index)
+ */
+ public UndirectedBlueprintsNode getNode1() {
+ return (UndirectedBlueprintsNode) this.getN1();
+ }
+
+ /**
+ * Gets the node2.
+ *
+ * @return second node connected by this edge (the node with the higher
+ * index)
+ */
+ public UndirectedBlueprintsNode getNode2() {
+ return (UndirectedBlueprintsNode) this.getN2();
+ }
+
+ @Override
+ public void setGDBEdgeId(Object gdbEdgeId) {
+ this.gdbEdgeId = gdbEdgeId;
+ }
+
+ @Override
+ public void setGraph(IGraph graph) {
+ if (graph instanceof BlueprintsGraph)
+ this.graph = (BlueprintsGraph) graph;
+ else
+ throw new RuntimeException("The parameter 'graph' must be an instance of " + BlueprintsGraph.class
+ + "but was " + graph.getClass());
+ }
+
+ @Override
+ public String toString()
+ {
+ return this.getN1().getIndex() + " " + separator + " " + this.getN2().getIndex();
+ }
+}
diff --git a/src/dna/graph/edges/UndirectedEdge.java b/src/dna/graph/edges/UndirectedEdge.java
index d4a9175a..608b8a49 100644
--- a/src/dna/graph/edges/UndirectedEdge.java
+++ b/src/dna/graph/edges/UndirectedEdge.java
@@ -3,7 +3,7 @@
import java.util.HashMap;
import dna.graph.Element;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.graph.nodes.UndirectedNode;
import dna.updates.update.Update;
@@ -35,7 +35,7 @@ public UndirectedEdge(UndirectedNode node1, UndirectedNode node2) {
* graph this undirected edge is belonging to (required to obtain
* node object pointers)
*/
- public UndirectedEdge(String s, Graph g) {
+ public UndirectedEdge(String s, IGraph g) {
String[] temp = s.contains(UndirectedEdge.separator) ? s
.split(UndirectedEdge.separator) : s
.split(Update.EdgeSeparator);
@@ -50,7 +50,7 @@ public UndirectedEdge(String s, Graph g) {
this.init(node1, node2);
}
- public UndirectedEdge(String s, Graph g, HashMap addedNodes) {
+ public UndirectedEdge(String s, IGraph g, HashMap addedNodes) {
String[] temp = s.contains(UndirectedEdge.separator) ? s
.split(UndirectedEdge.separator) : s
.split(Update.EdgeSeparator);
diff --git a/src/dna/graph/edges/UndirectedWeightedBlueprintsEdge.java b/src/dna/graph/edges/UndirectedWeightedBlueprintsEdge.java
new file mode 100644
index 00000000..ab7d85e6
--- /dev/null
+++ b/src/dna/graph/edges/UndirectedWeightedBlueprintsEdge.java
@@ -0,0 +1,117 @@
+package dna.graph.edges;
+
+import java.util.HashMap;
+
+import dna.graph.IGraph;
+import dna.graph.nodes.Node;
+import dna.graph.nodes.UndirectedBlueprintsNode;
+import dna.graph.weights.IWeightedEdge;
+import dna.graph.weights.Weight;
+
+/**
+ * The Class UndirectedWeightedBlueprintsEdge.
+ *
+ * @author Matthias
+ */
+public class UndirectedWeightedBlueprintsEdge extends UndirectedBlueprintsEdge implements
+ IWeightedEdge {
+
+ /** The weight. */
+ protected Weight weight;
+
+ /**
+ * Instantiates a new undirected weighted blueprints edge.
+ *
+ * @param src the src
+ * @param dst the dst
+ * @param weight the weight
+ */
+ public UndirectedWeightedBlueprintsEdge(UndirectedBlueprintsNode src, UndirectedBlueprintsNode dst,
+ Weight weight) {
+ super(src, dst);
+ this.weight = weight;
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints edge.
+ *
+ * @param s the s
+ * @param g the g
+ */
+ public UndirectedWeightedBlueprintsEdge(String s, IGraph g) {
+ super(s.split(Weight.WeightDelimiter)[0], g);
+ this.weight = g.getGraphDatastructures().newEdgeWeight(
+ s.split(Weight.WeightDelimiter)[1]);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints edge.
+ *
+ * @param s the s
+ * @param g the g
+ * @param addedNodes the added nodes
+ */
+ public UndirectedWeightedBlueprintsEdge(String s, IGraph g,
+ HashMap addedNodes) {
+ super(s.split(Weight.WeightDelimiter)[0], g, addedNodes);
+ this.weight = g.getGraphDatastructures().newEdgeWeight(
+ s.split(Weight.WeightDelimiter)[1]);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints edge.
+ *
+ * @param src the src
+ * @param dst the dst
+ * @param weight the weight
+ * @param e the e
+ */
+ public UndirectedWeightedBlueprintsEdge(UndirectedBlueprintsNode src, UndirectedBlueprintsNode dst,
+ Weight weight, Object gdbEdgeId) {
+ super(src, dst, gdbEdgeId);
+ this.setWeight(weight);
+ }
+
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#getWeight()
+ */
+ @Override
+ public Weight getWeight() {
+ if (this.getGDBEdge() == null)
+ return this.weight;
+
+ String weight = this.getGDBEdge().getProperty("weight");
+ if (weight == null)
+ this.setWeight(this.weight);
+ return this.weight;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#setWeight(dna.graph.weights.Weight)
+ */
+ @Override
+ public void setWeight(Weight weight) {
+ this.weight = weight;
+ if (this.getGDBEdge() == null)
+ return;
+ this.getGDBEdge().setProperty("weight", weight.asString());
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.UndirectedEdge#asString()
+ */
+ @Override
+ public String asString() {
+ return super.asString() + Weight.WeightDelimiter
+ + this.weight.asString();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.edges.UndirectedEdge#toString()
+ */
+ public String toString() {
+ return super.toString() + " [" + this.getWeight().asString() + "]";
+ }
+
+}
diff --git a/src/dna/graph/edges/UndirectedWeightedEdge.java b/src/dna/graph/edges/UndirectedWeightedEdge.java
index 2134d50a..690a43ee 100644
--- a/src/dna/graph/edges/UndirectedWeightedEdge.java
+++ b/src/dna/graph/edges/UndirectedWeightedEdge.java
@@ -2,7 +2,7 @@
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.graph.nodes.UndirectedNode;
import dna.graph.weights.IWeightedEdge;
@@ -19,13 +19,13 @@ public UndirectedWeightedEdge(UndirectedNode src, UndirectedNode dst,
this.weight = weight;
}
- public UndirectedWeightedEdge(String s, Graph g) {
+ public UndirectedWeightedEdge(String s, IGraph g) {
super(s.split(Weight.WeightDelimiter)[0], g);
this.weight = g.getGraphDatastructures().newEdgeWeight(
s.split(Weight.WeightDelimiter)[1]);
}
- public UndirectedWeightedEdge(String s, Graph g,
+ public UndirectedWeightedEdge(String s, IGraph g,
HashMap addedNodes) {
super(s.split(Weight.WeightDelimiter)[0], g, addedNodes);
this.weight = g.getGraphDatastructures().newEdgeWeight(
diff --git a/src/dna/graph/generators/GraphGenerator.java b/src/dna/graph/generators/GraphGenerator.java
index f208fd5b..a45e189a 100644
--- a/src/dna/graph/generators/GraphGenerator.java
+++ b/src/dna/graph/generators/GraphGenerator.java
@@ -1,6 +1,6 @@
package dna.graph.generators;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.util.parameters.Parameter;
import dna.util.parameters.ParameterList;
@@ -50,8 +50,8 @@ public GraphGenerator(String name, Parameter[] params,
}
}
-
- public Graph newGraphInstance() {
+
+ public IGraph newGraphInstance() {
GraphDataStructure newGDS = gds.clone();
return newGDS.newGraphInstance(this.getName(), this.timestampInit,
this.nodesInit, this.edgesInit);
@@ -65,10 +65,10 @@ public static String buildName(String name, GraphDataStructure gds) {
if (gds == null) {
return name;
}
- if (gds.createsDirected()) {
+ if (gds.createsDirected()/* || gds.createsDirectedGDB()*/) {
return "Directed" + name;
}
- if (gds.createsUndirected()) {
+ if (gds.createsUndirected()/* || gds.createsUndirectedGDB()*/) {
return "Undirected" + name;
}
return name;
diff --git a/src/dna/graph/generators/IGraphGenerator.java b/src/dna/graph/generators/IGraphGenerator.java
index 228ff06e..6ac12fb1 100644
--- a/src/dna/graph/generators/IGraphGenerator.java
+++ b/src/dna/graph/generators/IGraphGenerator.java
@@ -1,6 +1,6 @@
package dna.graph.generators;
-import dna.graph.Graph;
+import dna.graph.IGraph;
public interface IGraphGenerator {
/**
@@ -8,7 +8,7 @@ public interface IGraphGenerator {
*
* @return
*/
- public Graph generate();
+ public IGraph generate();
public String getName();
diff --git a/src/dna/graph/generators/canonical/CliqueGraph.java b/src/dna/graph/generators/canonical/CliqueGraph.java
index 3a93859a..a1972209 100644
--- a/src/dna/graph/generators/canonical/CliqueGraph.java
+++ b/src/dna/graph/generators/canonical/CliqueGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.canonical;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -26,8 +26,8 @@ public CliqueGraph(GraphDataStructure gds, int nodes) {
}
@Override
- public Graph generate() {
- Graph g = gds.newGraphInstance(this.getName(), this.timestampInit,
+ public IGraph generate() {
+ IGraph g = gds.newGraphInstance(this.getName(), this.timestampInit,
nodesInit, edgesInit);
for (int i = 0; i < this.nodesInit; i++) {
diff --git a/src/dna/graph/generators/canonical/Grid2dGraph.java b/src/dna/graph/generators/canonical/Grid2dGraph.java
index 1dde099b..b9a7c0ce 100644
--- a/src/dna/graph/generators/canonical/Grid2dGraph.java
+++ b/src/dna/graph/generators/canonical/Grid2dGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.canonical;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -29,8 +29,8 @@ public Grid2dGraph(GraphDataStructure gds, int x, int y,
}
@Override
- public Graph generate() {
- Graph g = this.newGraphInstance();
+ public IGraph generate() {
+ IGraph g = this.newGraphInstance();
Node[][] nodes = new Node[this.x][this.y];
int index = 0;
@@ -59,7 +59,7 @@ public Graph generate() {
return g;
}
- protected void connect(Graph g, Node src, Node dst) {
+ protected void connect(IGraph g, Node src, Node dst) {
Edge e = this.gds.newEdgeInstance(src, dst);
g.addEdge(e);
e.connectToNodes();
diff --git a/src/dna/graph/generators/canonical/Grid3dGraph.java b/src/dna/graph/generators/canonical/Grid3dGraph.java
index 48784c3e..d398b818 100644
--- a/src/dna/graph/generators/canonical/Grid3dGraph.java
+++ b/src/dna/graph/generators/canonical/Grid3dGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.canonical;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -31,8 +31,8 @@ public Grid3dGraph(GraphDataStructure gds, int x, int y, int z,
}
@Override
- public Graph generate() {
- Graph g = this.newGraphInstance();
+ public IGraph generate() {
+ IGraph g = this.newGraphInstance();
Node[][][] nodes = new Node[this.x][this.y][this.z];
int index = 0;
@@ -70,7 +70,7 @@ public Graph generate() {
return g;
}
- protected void connect(Graph g, Node src, Node dst) {
+ protected void connect(IGraph g, Node src, Node dst) {
Edge e = this.gds.newEdgeInstance(src, dst);
g.addEdge(e);
e.connectToNodes();
diff --git a/src/dna/graph/generators/canonical/HoneyCombGraph.java b/src/dna/graph/generators/canonical/HoneyCombGraph.java
index 820ef176..285750d7 100644
--- a/src/dna/graph/generators/canonical/HoneyCombGraph.java
+++ b/src/dna/graph/generators/canonical/HoneyCombGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.canonical;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -33,8 +33,8 @@ public HoneyCombGraph(GraphDataStructure gds, int combsX, int combsY,
}
@Override
- public Graph generate() {
- Graph g = this.newGraphInstance();
+ public IGraph generate() {
+ IGraph g = this.newGraphInstance();
HoneyComb[][] hcs = new HoneyComb[combsX][combsY];
for (int x = 0; x < combsX; x++) {
@@ -63,7 +63,7 @@ public Graph generate() {
return g;
}
- protected void connect(Graph g, HoneyComb[] row1, HoneyComb[] row2) {
+ protected void connect(IGraph g, HoneyComb[] row1, HoneyComb[] row2) {
for (int i = 0; i < row1.length; i++) {
Node src = row1[i].bottom;
Node dst = row2[i].top;
@@ -73,13 +73,13 @@ protected void connect(Graph g, HoneyComb[] row1, HoneyComb[] row2) {
}
}
- protected void connect(Graph g, HoneyComb hc1, HoneyComb hc2) {
+ protected void connect(IGraph g, HoneyComb hc1, HoneyComb hc2) {
Edge e = this.gds.newEdgeInstance(hc1.bottom, hc2.top);
g.addEdge(e);
e.connectToNodes();
}
- protected HoneyComb[] createRow(Graph g, GraphDataStructure gds, int count) {
+ protected HoneyComb[] createRow(IGraph g, GraphDataStructure gds, int count) {
HoneyComb[] row = new HoneyComb[count];
row[0] = new HoneyComb(g, gds);
for (int i = 1; i < row.length; i++) {
@@ -96,7 +96,7 @@ public static class HoneyComb {
public Node bottomRight;
public Node bottom;
- public HoneyComb(Graph g, GraphDataStructure gds) {
+ public HoneyComb(IGraph g, GraphDataStructure gds) {
top = addNode(g, gds);
topLeft = addNode(g, gds);
topRight = addNode(g, gds);
@@ -112,7 +112,7 @@ public HoneyComb(Graph g, GraphDataStructure gds) {
connect(g, gds, topRight, bottomRight);
}
- public HoneyComb(Graph g, GraphDataStructure gds, HoneyComb leftHC) {
+ public HoneyComb(IGraph g, GraphDataStructure gds, HoneyComb leftHC) {
top = addNode(g, gds);
topLeft = leftHC.topRight;
topRight = addNode(g, gds);
@@ -127,13 +127,13 @@ public HoneyComb(Graph g, GraphDataStructure gds, HoneyComb leftHC) {
connect(g, gds, topRight, bottomRight);
}
- protected static Node addNode(Graph g, GraphDataStructure gds) {
+ protected static Node addNode(IGraph g, GraphDataStructure gds) {
Node n = gds.newNodeInstance(g.getNodeCount());
g.addNode(n);
return n;
}
- protected static void connect(Graph g, GraphDataStructure gds,
+ protected static void connect(IGraph g, GraphDataStructure gds,
Node src, Node dst) {
Edge e = gds.newEdgeInstance(src, dst);
g.addEdge(e);
diff --git a/src/dna/graph/generators/canonical/RingGraph.java b/src/dna/graph/generators/canonical/RingGraph.java
index f767ee5d..83805411 100644
--- a/src/dna/graph/generators/canonical/RingGraph.java
+++ b/src/dna/graph/generators/canonical/RingGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.canonical;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -22,8 +22,8 @@ public RingGraph(GraphDataStructure gds, int nodes) {
}
@Override
- public Graph generate() {
- Graph g = gds.newGraphInstance(this.getName(), this.timestampInit,
+ public IGraph generate() {
+ IGraph g = gds.newGraphInstance(this.getName(), this.timestampInit,
nodesInit, edgesInit);
for (int i = 0; i < this.nodesInit; i++) {
diff --git a/src/dna/graph/generators/canonical/RingStarGraph.java b/src/dna/graph/generators/canonical/RingStarGraph.java
index 69a156f3..b19d4a8f 100644
--- a/src/dna/graph/generators/canonical/RingStarGraph.java
+++ b/src/dna/graph/generators/canonical/RingStarGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.canonical;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -23,8 +23,8 @@ public RingStarGraph(GraphDataStructure gds, int nodes) {
}
@Override
- public Graph generate() {
- Graph g = this.newGraphInstance();
+ public IGraph generate() {
+ IGraph g = this.newGraphInstance();
Node center = this.gds.newNodeInstance(0);
g.addNode(center);
@@ -43,18 +43,18 @@ public Graph generate() {
return g;
}
- protected void connect(Graph g, Node src, Node dst) {
+ protected void connect(IGraph g, Node src, Node dst) {
Edge e = this.gds.newEdgeInstance(src, dst);
g.addEdge(e);
e.connectToNodes();
}
- protected void add(Graph g, Node center, Node n) {
+ protected void add(IGraph g, Node center, Node n) {
g.addNode(n);
this.connect(g, center, n);
}
- protected void add(Graph g, Node center, Node previous, Node n) {
+ protected void add(IGraph g, Node center, Node previous, Node n) {
g.addNode(n);
this.connect(g, center, n);
this.connect(g, previous, n);
diff --git a/src/dna/graph/generators/canonical/StarGraph.java b/src/dna/graph/generators/canonical/StarGraph.java
index 512026cc..15daf5f8 100644
--- a/src/dna/graph/generators/canonical/StarGraph.java
+++ b/src/dna/graph/generators/canonical/StarGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.canonical;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -19,8 +19,8 @@ public StarGraph(GraphDataStructure gds, int nodes) {
}
@Override
- public Graph generate() {
- Graph g = this.newGraphInstance();
+ public IGraph generate() {
+ IGraph g = this.newGraphInstance();
Node center = this.gds.newNodeInstance(0);
g.addNode(center);
diff --git a/src/dna/graph/generators/combined/CombinedGraph.java b/src/dna/graph/generators/combined/CombinedGraph.java
index a754ef42..2094047f 100644
--- a/src/dna/graph/generators/combined/CombinedGraph.java
+++ b/src/dna/graph/generators/combined/CombinedGraph.java
@@ -2,7 +2,7 @@
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -69,14 +69,14 @@ private static int edgesInit(GraphGenerator[] ggs) {
@SuppressWarnings("unchecked")
@Override
- public Graph generate() {
+ public IGraph generate() {
if (this.ggs.length == 1) {
return this.ggs[0].generate();
}
- Graph g = this.newGraphInstance();
+ IGraph g = this.newGraphInstance();
- Graph[] components = new Graph[this.ggs.length];
+ IGraph[] components = new IGraph[this.ggs.length];
for (int i = 0; i < this.ggs.length; i++) {
components[i] = this.ggs[i].generate();
}
@@ -141,7 +141,7 @@ public Graph generate() {
return g;
}
- private static int getOtherIndex(Graph[] components, int current) {
+ private static int getOtherIndex(IGraph[] components, int current) {
int rand = Rand.rand.nextInt(components.length);
return rand >= current ? (rand + 1) % components.length : rand;
}
diff --git a/src/dna/graph/generators/connectivity/ConnectedGraph.java b/src/dna/graph/generators/connectivity/ConnectedGraph.java
index 5fd89b4d..82351f95 100644
--- a/src/dna/graph/generators/connectivity/ConnectedGraph.java
+++ b/src/dna/graph/generators/connectivity/ConnectedGraph.java
@@ -2,7 +2,7 @@
import java.util.Set;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -20,8 +20,8 @@ public ConnectedGraph(String name, GraphGenerator gg) {
}
@Override
- public Graph generate() {
- Graph g = this.gg.generate();
+ public IGraph generate() {
+ IGraph g = this.gg.generate();
Set exclude = this.getNodesToExclude(g);
for (Node n : exclude) {
g.removeNode(n);
@@ -38,6 +38,6 @@ public Graph generate() {
return g;
}
- protected abstract Set getNodesToExclude(Graph g);
+ protected abstract Set getNodesToExclude(IGraph g);
}
diff --git a/src/dna/graph/generators/connectivity/StronglyConnectedGraph.java b/src/dna/graph/generators/connectivity/StronglyConnectedGraph.java
index 4026ba02..faf6d3c8 100644
--- a/src/dna/graph/generators/connectivity/StronglyConnectedGraph.java
+++ b/src/dna/graph/generators/connectivity/StronglyConnectedGraph.java
@@ -5,7 +5,7 @@
import java.util.LinkedList;
import java.util.Set;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.DirectedEdge;
import dna.graph.generators.GraphGenerator;
@@ -20,7 +20,7 @@ public StronglyConnectedGraph(GraphGenerator gg) {
}
@Override
- protected Set getNodesToExclude(Graph g) {
+ protected Set getNodesToExclude(IGraph g) {
HashSet processed = new HashSet();
ArrayList> components = new ArrayList>();
diff --git a/src/dna/graph/generators/connectivity/WeaklyConnectedGraph.java b/src/dna/graph/generators/connectivity/WeaklyConnectedGraph.java
index aaa76a92..735816bf 100644
--- a/src/dna/graph/generators/connectivity/WeaklyConnectedGraph.java
+++ b/src/dna/graph/generators/connectivity/WeaklyConnectedGraph.java
@@ -5,7 +5,7 @@
import java.util.LinkedList;
import java.util.Set;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -19,7 +19,7 @@ public WeaklyConnectedGraph(GraphGenerator gg) {
}
@Override
- protected Set getNodesToExclude(Graph g) {
+ protected Set getNodesToExclude(IGraph g) {
HashSet processed = new HashSet();
ArrayList> components = new ArrayList>();
diff --git a/src/dna/graph/generators/evolvingNetworks/BarabasiAlbertGraph.java b/src/dna/graph/generators/evolvingNetworks/BarabasiAlbertGraph.java
index 1cb76aa3..4b9f5269 100644
--- a/src/dna/graph/generators/evolvingNetworks/BarabasiAlbertGraph.java
+++ b/src/dna/graph/generators/evolvingNetworks/BarabasiAlbertGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.evolvingNetworks;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
import dna.graph.generators.random.RandomGraph;
@@ -35,12 +35,12 @@ public BarabasiAlbertGraph(GraphDataStructure gds, int startNodes,
}
@Override
- public Graph generate() {
+ public IGraph generate() {
GraphGenerator gg = new RandomGraph(this.gds, this.startNodes,
this.startEdges);
BatchGenerator bg = new BarabasiAlbertBatch(this.nodesToAdd,
this.edgesPerNode);
- Graph g = gg.generate();
+ IGraph g = gg.generate();
Batch b = bg.generate(g);
b.apply(g);
g.setTimestamp(0);
diff --git a/src/dna/graph/generators/evolvingNetworks/PositiveFeedbackPreferenceGraph.java b/src/dna/graph/generators/evolvingNetworks/PositiveFeedbackPreferenceGraph.java
index b0a617d6..4f8cb6b5 100644
--- a/src/dna/graph/generators/evolvingNetworks/PositiveFeedbackPreferenceGraph.java
+++ b/src/dna/graph/generators/evolvingNetworks/PositiveFeedbackPreferenceGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.evolvingNetworks;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
import dna.graph.generators.random.RandomGraph;
@@ -35,11 +35,11 @@ public PositiveFeedbackPreferenceGraph(GraphDataStructure gds, int startNodes,
}
@Override
- public Graph generate() {
+ public IGraph generate() {
GraphGenerator gg = new RandomGraph(this.gds, this.startNodes,
this.startEdges);
- Graph g = gg.generate();
+ IGraph g = gg.generate();
if(this.nodesToAdd>0){
diff --git a/src/dna/graph/generators/konect/KonectGraph.java b/src/dna/graph/generators/konect/KonectGraph.java
index 3619ee5a..a86f7c1a 100644
--- a/src/dna/graph/generators/konect/KonectGraph.java
+++ b/src/dna/graph/generators/konect/KonectGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.konect;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
import dna.graph.generators.konect.KonectReader.KonectGraphType;
@@ -40,8 +40,8 @@ public KonectGraph(KonectReader r, KonectGraphType graphType,
}
@Override
- public Graph generate() {
- Graph g = this.newGraphInstance();
+ public IGraph generate() {
+ IGraph g = this.newGraphInstance();
int processed = 0;
while (true) {
@@ -86,19 +86,19 @@ protected KonectEdge readNextEdge() {
return this.r.readEdge();
}
- protected void addIfNecessary(Graph g, Node n) {
+ protected void addIfNecessary(IGraph g, Node n) {
if (!g.containsNode(n)) {
g.addNode(n);
}
}
- protected void removeIfNecessary(Graph g, Node n) {
+ protected void removeIfNecessary(IGraph g, Node n) {
if (this.removeZeroDegreeNodes && n.getDegree() == 0) {
g.removeNode(n);
}
}
- protected void processEdge(Graph g, KonectEdge edge) {
+ protected void processEdge(IGraph g, KonectEdge edge) {
if (edge.n1 == edge.n2) {
return;
}
diff --git a/src/dna/graph/generators/random/RandomGraph.java b/src/dna/graph/generators/random/RandomGraph.java
index fbba8f9c..884812a5 100644
--- a/src/dna/graph/generators/random/RandomGraph.java
+++ b/src/dna/graph/generators/random/RandomGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.random;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -23,8 +23,8 @@ protected RandomGraph(String name, Parameter[] parameters,
}
@Override
- public Graph generate() {
- Graph graph = this.newGraphInstance();
+ public IGraph generate() {
+ IGraph graph = this.newGraphInstance();
for (int i = 0; i < this.nodesInit; i++) {
Node node = this.gds.newNodeInstance(i);
diff --git a/src/dna/graph/generators/timestamped/TimestampedGraph.java b/src/dna/graph/generators/timestamped/TimestampedGraph.java
index e8eb7384..25e804b9 100644
--- a/src/dna/graph/generators/timestamped/TimestampedGraph.java
+++ b/src/dna/graph/generators/timestamped/TimestampedGraph.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -80,14 +80,14 @@ public TimestampedGraph(TimestampedReader reader, GraphDataStructure gds,
}
@Override
- public Graph generate() {
+ public IGraph generate() {
try {
this.reader.read();
} catch (IOException e1) {
e1.printStackTrace();
return null;
}
- Graph g = this.newGraphInstance();
+ IGraph g = this.newGraphInstance();
TimestampedEdge e = null;
int duplicateEdges = 0;
int loops = 0;
@@ -122,7 +122,7 @@ public Graph generate() {
return g;
}
- private TimestampedEdge next(Graph g) {
+ private TimestampedEdge next(IGraph g) {
switch (this.type) {
case EDGE_COUNT:
if (g.getEdgeCount() >= this.parameter) {
diff --git a/src/dna/graph/generators/util/BatchBasedGraph.java b/src/dna/graph/generators/util/BatchBasedGraph.java
index 097986f3..388a6728 100644
--- a/src/dna/graph/generators/util/BatchBasedGraph.java
+++ b/src/dna/graph/generators/util/BatchBasedGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
import dna.updates.batch.Batch;
@@ -24,8 +24,8 @@ public BatchBasedGraph(GraphDataStructure gds, GraphGenerator gg,
}
@Override
- public Graph generate() {
- Graph g = this.gg.generate();
+ public IGraph generate() {
+ IGraph g = this.gg.generate();
for (int i = 0; i < this.times; i++) {
if (!this.bg.isFurtherBatchPossible(g)) {
break;
diff --git a/src/dna/graph/generators/util/CombiningGraph.java b/src/dna/graph/generators/util/CombiningGraph.java
index 85452d81..d6545afc 100644
--- a/src/dna/graph/generators/util/CombiningGraph.java
+++ b/src/dna/graph/generators/util/CombiningGraph.java
@@ -2,17 +2,17 @@
import java.util.HashMap;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.metrics.parallelization.partitioning.Partition;
public class CombiningGraph {
- public static Graph combine(GraphDataStructure gds, String name,
+ public static IGraph combine(GraphDataStructure gds, String name,
Partition[] partitions) {
- Graph[] graphs = new Graph[partitions.length];
+ IGraph[] graphs = new IGraph[partitions.length];
for (int i = 0; i < partitions.length; i++) {
graphs[i] = partitions[i].getGraph();
}
@@ -27,16 +27,16 @@ public static Graph combine(GraphDataStructure gds, String name,
// return combine(gds, name, graphs);
// }
- public static Graph combine(GraphDataStructure gds, String name,
- Graph... graphs) {
+ public static IGraph combine(GraphDataStructure gds, String name,
+ IGraph... graphs) {
int nodes = 0;
int edges = 0;
- for (Graph graph : graphs) {
+ for (IGraph graph : graphs) {
nodes += graph.getNodeCount();
edges += graph.getEdgeCount();
}
- Graph g = gds.newGraphInstance(name, 0, nodes, edges);
+ IGraph g = gds.newGraphInstance(name, 0, nodes, edges);
int index = 0;
HashMap[] map = new HashMap[graphs.length];
diff --git a/src/dna/graph/generators/util/EmptyGraph.java b/src/dna/graph/generators/util/EmptyGraph.java
index ff85e54c..0afab212 100644
--- a/src/dna/graph/generators/util/EmptyGraph.java
+++ b/src/dna/graph/generators/util/EmptyGraph.java
@@ -1,6 +1,6 @@
package dna.graph.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
@@ -15,7 +15,7 @@ public EmptyGraph(GraphDataStructure gds) {
}
@Override
- public Graph generate() {
+ public IGraph generate() {
return this.newGraphInstance();
}
diff --git a/src/dna/graph/generators/util/ReadableDirGraph.java b/src/dna/graph/generators/util/ReadableDirGraph.java
index 7e95cc08..f285f519 100644
--- a/src/dna/graph/generators/util/ReadableDirGraph.java
+++ b/src/dna/graph/generators/util/ReadableDirGraph.java
@@ -3,7 +3,7 @@
import java.io.FilenameFilter;
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
import dna.io.GraphReader;
@@ -86,7 +86,7 @@ public ReadableDirGraph(String dir, FilenameFilter filter,
}
@Override
- public Graph generate() {
+ public IGraph generate() {
this.index = (this.index + 1) % this.filenames.length;
try {
return GraphReader.read(this.dir, this.filenames[this.index]);
diff --git a/src/dna/graph/generators/util/ReadableEdgeListFileGraph.java b/src/dna/graph/generators/util/ReadableEdgeListFileGraph.java
index a680994d..b89188c6 100644
--- a/src/dna/graph/generators/util/ReadableEdgeListFileGraph.java
+++ b/src/dna/graph/generators/util/ReadableEdgeListFileGraph.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
import dna.io.EdgeListGraphReader;
@@ -28,9 +28,9 @@ public ReadableEdgeListFileGraph(String dir, String filename,
}
@Override
- public Graph generate() {
+ public IGraph generate() {
try {
- Graph g = EdgeListGraphReader.read(this.dir, this.filename,
+ IGraph g = EdgeListGraphReader.read(this.dir, this.filename,
this.separator, this.gds);
return g;
} catch (IOException e) {
diff --git a/src/dna/graph/generators/util/ReadableFileGraph.java b/src/dna/graph/generators/util/ReadableFileGraph.java
index 20316bf5..b463dc77 100644
--- a/src/dna/graph/generators/util/ReadableFileGraph.java
+++ b/src/dna/graph/generators/util/ReadableFileGraph.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
import dna.io.GraphReader;
@@ -52,7 +52,7 @@ public ReadableFileGraph(String dir, String filename, GraphDataStructure gds)
}
@Override
- public Graph generate() {
+ public IGraph generate() {
try {
if (this.gds == null) {
return GraphReader.read(this.dir, this.filename);
diff --git a/src/dna/graph/generators/util/RepeatableReadableFileGraph.java b/src/dna/graph/generators/util/RepeatableReadableFileGraph.java
new file mode 100644
index 00000000..a68cb84e
--- /dev/null
+++ b/src/dna/graph/generators/util/RepeatableReadableFileGraph.java
@@ -0,0 +1,58 @@
+package dna.graph.generators.util;
+
+import java.io.IOException;
+
+import dna.graph.IGraph;
+import dna.graph.datastructures.GraphDataStructure;
+
+/**
+ *
+ * Graph generator that reads a graph from a specified file. Hence, every
+ * generated graph is the same. If no GraphDataStructure is given, the one
+ * specified in the respective graph is used.
+ * Once the graph has been generated for the first time, the generate
+ * function will always return the same value.
+ *
+ * @author Matthias
+ *
+ */
+public class RepeatableReadableFileGraph extends ReadableFileGraph {
+
+ private IGraph currentGraph = null;
+
+ /**
+ *
+ * @param dir
+ * directory containing the graph file
+ * @param filename
+ * name of the graph file
+ * @throws IOException
+ */
+ public RepeatableReadableFileGraph(String dir, String filename) throws IOException {
+ super(dir, filename, null);
+ }
+
+ /**
+ *
+ * @param dir
+ * directory containing the graph file
+ * @param filename
+ * name of the graph file
+ * @param gds
+ * GraphDataStructure to be used when reading in the graphs
+ * @throws IOException
+ */
+ public RepeatableReadableFileGraph(String dir, String filename, GraphDataStructure gds)
+ throws IOException {
+ super(dir, filename, gds);
+ }
+
+ @Override
+ public IGraph generate() {
+ if (this.currentGraph == null)
+ this.currentGraph = super.generate();
+
+ return this.currentGraph;
+ }
+
+}
diff --git a/src/dna/graph/generators/zalando/ZalandoGraphGenerator.java b/src/dna/graph/generators/zalando/ZalandoGraphGenerator.java
index 6ff48246..57eb321f 100644
--- a/src/dna/graph/generators/zalando/ZalandoGraphGenerator.java
+++ b/src/dna/graph/generators/zalando/ZalandoGraphGenerator.java
@@ -6,7 +6,7 @@
import java.util.HashMap;
import java.util.Map;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.edges.DirectedWeightedEdge;
@@ -49,7 +49,7 @@ abstract class ZalandoGraphGenerator extends GraphGenerator {
* The result of any {@link #generate()} call in any subclass of
* {@linkZalandoGraphGenerator}.
*/
- Graph graph;
+ IGraph graph;
/**
* If this {@link EventFilter} is not null, only events that passes this
@@ -486,7 +486,7 @@ private int calculcateEdgeWeight(Edge edge, int weight) {
}
@Override
- public Graph generate() {
+ public IGraph generate() {
final EventReader reader = new EventReader(this.pathProducts,
this.isGzippedProducts, this.pathLog, this.isGzippedLog);
diff --git a/src/dna/graph/nodes/DirectedBlueprintsNode.java b/src/dna/graph/nodes/DirectedBlueprintsNode.java
new file mode 100644
index 00000000..e8de8e26
--- /dev/null
+++ b/src/dna/graph/nodes/DirectedBlueprintsNode.java
@@ -0,0 +1,400 @@
+package dna.graph.nodes;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import com.tinkerpop.blueprints.Direction;
+import com.tinkerpop.blueprints.Vertex;
+
+import dna.graph.BlueprintsGraph;
+import dna.graph.IElement;
+import dna.graph.IGraph;
+import dna.graph.datastructures.DataStructure.ListType;
+import dna.graph.datastructures.GraphDataStructure;
+import dna.graph.datastructures.IDataStructure;
+import dna.graph.edges.DirectedBlueprintsEdge;
+import dna.graph.edges.Edge;
+import dna.util.Log;
+import dna.util.MathHelper;
+
+/**
+ * The Class DirectedBlueprintsNode.
+ *
+ * @author Matthias
+ */
+public class DirectedBlueprintsNode extends DirectedNode implements IGDBNode {
+
+ private Object gdbNodeId;
+
+ /** The gds. */
+ protected GraphDataStructure gds;
+
+ /** The graph. */
+ protected BlueprintsGraph graph;
+
+ /** The index. */
+ private int index;
+
+ /**
+ * Instantiates a new directed blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ */
+ public DirectedBlueprintsNode(int i, GraphDataStructure gds) {
+ super(i, gds);
+ this.setIndex(i);
+ }
+
+ /**
+ * Instantiates a new directed blueprints node.
+ *
+ * @param i the index
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public DirectedBlueprintsNode(int i, GraphDataStructure gds, IGraph graph) {
+ this(i, gds);
+ this.setIndex(i);
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new directed blueprints node.
+ *
+ * @param i the index
+ * @param gds the gds
+ * @param vertex the vertex
+ * @param graph the graph
+ */
+ public DirectedBlueprintsNode(int i, GraphDataStructure gds, Object gdbNodeId,
+ IGraph graph) {
+ super(i, gds);
+ this.setGDBNodeId(gdbNodeId);
+ this.setIndex(i);
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new directed blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ */
+ public DirectedBlueprintsNode(String str, GraphDataStructure gds) {
+ this(MathHelper.parseInt(str), gds);
+ }
+
+ /**
+ * Instantiates a new directed blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public DirectedBlueprintsNode(String str, GraphDataStructure gds, IGraph graph) {
+ this(MathHelper.parseInt(str), gds, graph);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#addEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean addEdge(Edge edge) {
+ if (edge == null || !(edge instanceof DirectedBlueprintsEdge))
+ return false;
+ DirectedBlueprintsEdge e = (DirectedBlueprintsEdge) edge;
+
+ if (e.getGDBEdge() != null && this.graph.containsEdge(edge)) {
+ return false;
+ }
+
+ return this.graph.addEdge(e);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#getEdges()
+ */
+ @Override
+ public Iterable getEdges() {
+ Collection result = new ArrayList();
+ Edge edge = null;
+ for (com.tinkerpop.blueprints.Edge e : this.getGDBNode().getEdges(Direction.BOTH, "IGDBEdge"))
+ {
+ edge = this.graph.getEdge(e);
+
+ if (!result.contains(edge))
+ result.add(edge);
+ }
+
+ return new ArrayList(result);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.nodes.IGDBNode#getVertex()
+ */
+ @Override
+ public Vertex getGDBNode() {
+ if (this.graph == null || this.gdbNodeId == null)
+ return null;
+ else
+ return this.graph.getGDBNode(this.gdbNodeId);
+ }
+
+ @Override
+ public Object getGDBNodeId() {
+ return this.gdbNodeId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.nodes.IGDBNode#getGraph()
+ */
+ @Override
+ public IGraph getGraph() {
+ return this.graph;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#getIncomingEdges()
+ */
+ @Override
+ public Iterable getIncomingEdges() {
+ return this.in();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#getInDegree()
+ */
+ @Override
+ public int getInDegree() {
+ return this.in().size();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.Node#getIndex()
+ */
+ @Override
+ public int getIndex() {
+ if (this.getGDBNode() == null)
+ return this.index;
+ Integer idx = (Integer) this.getGDBNode().getProperty("index");
+ if (idx == null)
+ this.setIndex(this.index);
+ return this.index;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#getNeighborCount()
+ */
+ @Override
+ public int getNeighborCount() {
+ return this.neighbors().size();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#getNeighbors()
+ */
+ @Override
+ public Iterable getNeighbors() {
+ return this.neighbors();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#getOutDegree()
+ */
+ @Override
+ public int getOutDegree() {
+ return this.out().size();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#getOutgoingEdges()
+ */
+ @Override
+ public Iterable getOutgoingEdges() {
+ return this.out();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#hasEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean hasEdge(Edge edge) {
+ if (edge == null || !(edge instanceof DirectedBlueprintsEdge))
+ return false;
+ DirectedBlueprintsEdge e = (DirectedBlueprintsEdge) edge;
+ return e.getSrcIndex() == this.index && this.out().contains(e)
+ || e.getDstIndex() == this.index && this.in().contains(e);
+ }
+
+ @Override
+ public boolean hasEdge(Node n1, Node n2) {
+ if (n1 == null || n2 == null
+ || !(n1 instanceof DirectedBlueprintsNode)
+ || !(n2 instanceof DirectedBlueprintsNode))
+ return false;
+
+ return this.graph.getEdge(n1, n2) != null;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#hasNeighbor(dna.graph.nodes.DirectedNode)
+ */
+ @Override
+ public boolean hasNeighbor(DirectedNode n) {
+ return this.neighbors().contains(n);
+ }
+
+ /**
+ * Return the collection of incoming edges.
+ *
+ * @return the collection of incoming edges
+ */
+ protected Collection in() {
+ Collection result = new ArrayList();
+ Iterable edges = this.getGDBNode().getEdges(Direction.IN, "IGDBEdge");
+
+ try{
+ if (this.getGDBNode() != null) {
+ for (com.tinkerpop.blueprints.Edge e : edges) {
+
+ result.add(this.graph.getEdge(e));
+ }
+ }
+ return result;
+ }
+ finally{
+ result = null;
+ edges = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#init(dna.graph.datastructures.GraphDataStructure)
+ */
+ @Override
+ public void init(GraphDataStructure gds) {
+ this.gds = gds;
+ }
+
+ /**
+ * Neighbors of this node.
+ *
+ * @return the collection
+ */
+ private Collection neighbors() {
+ Collection result = new HashSet();
+
+ try{
+ for (IElement e : this.out()) {
+ if (this.in().contains(((DirectedBlueprintsEdge) e).invert())) {
+ result.add(((DirectedBlueprintsEdge) e).getDst());
+ }
+ }
+ return result;
+ }
+ finally {
+ result = null;
+ }
+ }
+
+ /**
+ * Return the collection of outgoing edges.
+ *
+ * @return the collection of outgoing edges
+ */
+ protected Collection out() {
+ Collection result = new ArrayList();
+ Iterable edges = null;
+ try {
+ edges = this.getGDBNode().getEdges(Direction.OUT, "IGDBEdge");
+ } catch (Exception e1) {
+ System.out.println(this.toString());
+ e1.printStackTrace();
+ }
+
+ try{
+ if (this.getGDBNode() != null) {
+ for (com.tinkerpop.blueprints.Edge e : edges) {
+
+ result.add(this.graph.getEdge(e));
+ }
+ }
+ return result;
+ }
+ catch(Exception ex) {
+ System.out.println(this.toString());
+ ex.printStackTrace();
+ return null;
+ }
+ finally{
+ result = null;
+ edges = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#removeEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean removeEdge(Edge edge) {
+ if (edge == null || !(edge instanceof DirectedBlueprintsEdge))
+ return false;
+ DirectedBlueprintsEdge e = (DirectedBlueprintsEdge) edge;
+
+ return this.graph.removeEdge(e);
+ }
+
+ @Override
+ public void setGDBNodeId(Object gdbNodeId) {
+ this.gdbNodeId = gdbNodeId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.nodes.IGDBNode#setGraph(com.tinkerpop.blueprints.Graph)
+ */
+ @Override
+ public void setGraph(IGraph graph) {
+ if (graph instanceof BlueprintsGraph)
+ this.graph = (BlueprintsGraph) graph;
+ else
+ throw new RuntimeException("The parameter 'graph' must be an instance of " + BlueprintsGraph.class
+ + "but was " + graph.getClass());
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.Node#setIndex(int)
+ */
+ @Override
+ public void setIndex(int index) {
+ this.index = index;
+ if (this.getGDBNode() == null)
+ return;
+ this.getGDBNode().setProperty("index", index);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#switchDataStructure(dna.graph.datastructures.DataStructure.ListType, dna.graph.datastructures.IDataStructure)
+ */
+ @Override
+ public void switchDataStructure(ListType type,
+ IDataStructure newDatastructure) {
+ Log.info("Switch datastructure is not available for " + DirectedBlueprintsNode.class);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedNode#toString()
+ */
+ @Override
+ public String toString() {
+ return "" + this.getIndex() + " (" + this.in().size() + "/"
+ + this.out().size() + ")";
+ }
+}
diff --git a/src/dna/graph/nodes/DirectedWeightedBlueprintsNode.java b/src/dna/graph/nodes/DirectedWeightedBlueprintsNode.java
new file mode 100644
index 00000000..c0a99516
--- /dev/null
+++ b/src/dna/graph/nodes/DirectedWeightedBlueprintsNode.java
@@ -0,0 +1,181 @@
+package dna.graph.nodes;
+
+import dna.graph.IGraph;
+import dna.graph.datastructures.GraphDataStructure;
+import dna.graph.weights.IWeightedNode;
+import dna.graph.weights.Weight;
+
+/**
+ * The Class DirectedWeightedBlueprintsNode.
+ *
+ * @author Matthias
+ */
+public class DirectedWeightedBlueprintsNode extends DirectedBlueprintsNode implements
+ IWeightedNode {
+
+ /** The weight. */
+ private Weight weight;
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ */
+ public DirectedWeightedBlueprintsNode(int i, GraphDataStructure gds) {
+ super(i, gds);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param i the i
+ * @param weight the weight
+ * @param gds the gds
+ */
+ public DirectedWeightedBlueprintsNode(int i, Weight weight, GraphDataStructure gds) {
+ this(i, gds);
+ this.setWeight(weight);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ */
+ public DirectedWeightedBlueprintsNode(String str, GraphDataStructure gds) {
+ super(str.split(Weight.WeightDelimiter)[0], gds);
+ this.setWeight(gds.newNodeWeight(str.split(Weight.WeightDelimiter)[1]));
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ * @param vertex the vertex
+ */
+ public DirectedWeightedBlueprintsNode(int i, GraphDataStructure gds, Object gdbNodeId) {
+ this(i, gds);
+ this.setGDBNodeId(gdbNodeId);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public DirectedWeightedBlueprintsNode(int i, GraphDataStructure gds, IGraph graph) {
+ super(i, gds);
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param i the i
+ * @param weight the weight
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public DirectedWeightedBlueprintsNode(int i, Weight weight,
+ GraphDataStructure gds, IGraph graph) {
+ this(i, gds);
+ this.setWeight(weight);
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public DirectedWeightedBlueprintsNode(String str, GraphDataStructure gds,
+ IGraph graph) {
+ super(str.split(Weight.WeightDelimiter)[0], gds);
+ this.setWeight(gds.newNodeWeight(str.split(Weight.WeightDelimiter)[1]));
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ * @param vertex the vertex
+ * @param graph the graph
+ */
+ public DirectedWeightedBlueprintsNode(int i, GraphDataStructure gds,
+ Object gdbNodeId, IGraph graph) {
+ super(i, gds, gdbNodeId, graph);
+ }
+
+ /**
+ * Instantiates a new directed weighted blueprints node.
+ *
+ * @param i the i
+ * @param weight the weight
+ * @param gds the gds
+ * @param vertex the vertex
+ * @param graph the graph
+ */
+ public DirectedWeightedBlueprintsNode(int i, Weight weight,
+ GraphDataStructure gds, Object gdbNodeId, IGraph graph) {
+ this(i, gds, gdbNodeId, graph);
+ this.setWeight(weight);
+ }
+
+ @Override
+ public boolean hasEdge(Node n1, Node n2) {
+ if (n1 == null || n2 == null
+ || !(n1 instanceof DirectedWeightedBlueprintsNode)
+ || !(n2 instanceof DirectedWeightedBlueprintsNode))
+ return false;
+
+ return this.graph.getEdge(n1, n2) != null;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#getWeight()
+ */
+ @Override
+ public Weight getWeight() {
+ if (this.getGDBNode() == null) return this.weight;
+
+ if (this.getGDBNode().getProperty("weight") == null)
+ this.setWeight(this.weight);
+ return this.weight;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#setWeight(dna.graph.weights.Weight)
+ */
+ @Override
+ public void setWeight(Weight weight) {
+ this.weight = weight;
+ if (this.getGDBNode() == null) return;
+ this.getGDBNode().setProperty("weight", weight.asString());
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.Node#asString()
+ */
+ @Override
+ public String asString() {
+ return super.asString() + Weight.WeightDelimiter
+ + this.getWeight().asString();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.DirectedBlueprintsNode#toString()
+ */
+ public String toString() {
+ return super.toString() + " [" + this.getWeight().asString() + "]";
+ }
+
+}
diff --git a/src/dna/graph/nodes/IGDBNode.java b/src/dna/graph/nodes/IGDBNode.java
new file mode 100644
index 00000000..25b8285d
--- /dev/null
+++ b/src/dna/graph/nodes/IGDBNode.java
@@ -0,0 +1,17 @@
+package dna.graph.nodes;
+
+import dna.graph.IGraph;
+
+public interface IGDBNode {
+
+ public abstract void setGraph(IGraph graph);
+
+ public abstract IGraph getGraph();
+
+ public abstract void setGDBNodeId(Object gdbNodeId);
+
+ public abstract Object getGDBNodeId();
+
+ public abstract N getGDBNode();
+
+}
\ No newline at end of file
diff --git a/src/dna/graph/nodes/UndirectedBlueprintsNode.java b/src/dna/graph/nodes/UndirectedBlueprintsNode.java
new file mode 100644
index 00000000..7a5f9291
--- /dev/null
+++ b/src/dna/graph/nodes/UndirectedBlueprintsNode.java
@@ -0,0 +1,256 @@
+package dna.graph.nodes;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import com.google.common.collect.Iterables;
+import com.tinkerpop.blueprints.Direction;
+import com.tinkerpop.blueprints.Vertex;
+
+import dna.graph.BlueprintsGraph;
+import dna.graph.IElement;
+import dna.graph.IGraph;
+import dna.graph.datastructures.DataStructure.ListType;
+import dna.graph.datastructures.GraphDataStructure;
+import dna.graph.datastructures.IDataStructure;
+import dna.graph.edges.Edge;
+import dna.graph.edges.UndirectedBlueprintsEdge;
+import dna.util.Log;
+import dna.util.MathHelper;
+
+/**
+ * The Class UndirectedBlueprintsNode.
+ *
+ * @author Matthias
+ */
+public class UndirectedBlueprintsNode extends UndirectedNode implements
+ IGDBNode {
+
+ private Object gdbNodeId;
+
+ /** The gds. */
+ protected GraphDataStructure gds;
+
+ /** The graph. */
+ protected BlueprintsGraph graph;
+
+ /**
+ * Instantiates a new undirected blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ */
+ public UndirectedBlueprintsNode(int i, GraphDataStructure gds) {
+ super(i, gds);
+ this.setIndex(i);
+ }
+
+ /**
+ * Instantiates a new undirected blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public UndirectedBlueprintsNode(int i, GraphDataStructure gds, IGraph graph) {
+ super(i, gds);
+ this.setIndex(i);
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new undirected blueprints node.
+ *
+ * @param i the i
+ * @param gds the gds
+ * @param getGDBNode() the getGDBNode()
+ * @param graph the graph
+ */
+ public UndirectedBlueprintsNode(Integer i, GraphDataStructure gds,
+ Object gdbNodeId, IGraph graph) {
+ super(i, gds);
+ this.setGDBNodeId(gdbNodeId);
+ this.setIndex(i);
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new undirected blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ */
+ public UndirectedBlueprintsNode(String str, GraphDataStructure gds) {
+ this(MathHelper.parseInt(str), gds);
+ }
+
+ /**
+ * Instantiates a new undirected blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public UndirectedBlueprintsNode(String str, GraphDataStructure gds,
+ IGraph graph) {
+ this(MathHelper.parseInt(str), gds, graph);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#addEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean addEdge(Edge edge) {
+ if (!(edge instanceof UndirectedBlueprintsEdge))
+ return false;
+ UndirectedBlueprintsEdge e = (UndirectedBlueprintsEdge) edge;
+
+ if (e.getGDBEdge() != null && this.graph.containsEdge(edge)) {
+ return false;
+ }
+
+ return this.graph.addEdge(e);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#getDegree()
+ */
+ @Override
+ public int getDegree() {
+ return Iterables.size(this.getEdges());
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#getEdges()
+ */
+ @Override
+ public Iterable getEdges() {
+ Collection result = new ArrayList();
+ for (com.tinkerpop.blueprints.Edge e : getGDBNode().getEdges(Direction.BOTH,
+ "IGDBEdge")) {
+ Edge edge = this.graph.getEdge(e);
+
+ if (!result.contains((Edge) edge))
+ result.add((Edge) edge);
+ }
+
+ return new ArrayList(result);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.nodes.IGDBNode#getVertex()
+ */
+ @Override
+ public Vertex getGDBNode() {
+ if (this.graph == null || this.gdbNodeId == null)
+ return null;
+ else
+ return this.graph.getGDBNode(this.gdbNodeId);
+ }
+
+ @Override
+ public Object getGDBNodeId() {
+ return this.gdbNodeId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.nodes.IGDBNode#getGraph()
+ */
+ @Override
+ public IGraph getGraph() {
+ return this.graph;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.Node#getIndex()
+ */
+ @Override
+ public int getIndex() {
+ if (this.getGDBNode() == null)
+ return this.index;
+ Integer idx = (Integer) this.getGDBNode().getProperty("index");
+ if (idx == null)
+ this.setIndex(this.index);
+ return this.index;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#hasEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean hasEdge(Edge edge) {
+ if (edge == null || !(edge instanceof UndirectedBlueprintsEdge))
+ return false;
+ UndirectedBlueprintsEdge e = (UndirectedBlueprintsEdge) edge;
+
+ return ((ArrayList) this.getEdges()).contains(e);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#init(dna.graph.datastructures.GraphDataStructure)
+ */
+ @Override
+ public void init(GraphDataStructure gds) {
+ this.gds = gds;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#removeEdge(dna.graph.edges.Edge)
+ */
+ @Override
+ public boolean removeEdge(Edge edge) {
+ if (edge == null || !(edge instanceof UndirectedBlueprintsEdge))
+ return false;
+ UndirectedBlueprintsEdge e = (UndirectedBlueprintsEdge) edge;
+
+ return this.graph.removeEdge(e);
+ }
+
+ @Override
+ public void setGDBNodeId(Object gdbNodeId) {
+ this.gdbNodeId = gdbNodeId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see dna.graph.nodes.IGDBNode#setGraph(com.tinkerpop.blueprints.Graph)
+ */
+ @Override
+ public void setGraph(IGraph graph) {
+ if (graph instanceof BlueprintsGraph)
+ this.graph = (BlueprintsGraph) graph;
+ else
+ throw new RuntimeException(
+ "The parameter 'graph' must be an instance of "
+ + BlueprintsGraph.class + "but was "
+ + graph.getClass());
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.Node#setIndex(int)
+ */
+ @Override
+ public void setIndex(int index) {
+ this.index = index;
+ if (this.getGDBNode() == null)
+ return;
+ this.getGDBNode().setProperty("index", index);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#switchDataStructure(dna.graph.datastructures.DataStructure.ListType, dna.graph.datastructures.IDataStructure)
+ */
+ @Override
+ public void switchDataStructure(ListType type,
+ IDataStructure newDatastructure) {
+ Log.info("Switch datastructure is not available for " + UndirectedBlueprintsNode.class);
+ }
+
+ public String toString() {
+ return "" + this.getIndex() + " (" + this.getDegree() + ")";
+ }
+}
diff --git a/src/dna/graph/nodes/UndirectedWeightedBlueprintsNode.java b/src/dna/graph/nodes/UndirectedWeightedBlueprintsNode.java
new file mode 100644
index 00000000..db702455
--- /dev/null
+++ b/src/dna/graph/nodes/UndirectedWeightedBlueprintsNode.java
@@ -0,0 +1,160 @@
+package dna.graph.nodes;
+
+import dna.graph.IGraph;
+import dna.graph.datastructures.GraphDataStructure;
+import dna.graph.weights.IWeightedNode;
+import dna.graph.weights.Weight;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class UndirectedWeightedBlueprintsNode.
+ */
+public class UndirectedWeightedBlueprintsNode extends UndirectedBlueprintsNode implements
+ IWeightedNode {
+
+ /** The weight. */
+ protected Weight weight;
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param i the index
+ * @param gds the gds
+ */
+ public UndirectedWeightedBlueprintsNode(int i, GraphDataStructure gds) {
+ super(i, gds);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param i the index
+ * @param weight the weight
+ * @param gds the gds
+ */
+ public UndirectedWeightedBlueprintsNode(int i, Weight weight,
+ GraphDataStructure gds) {
+ this(i, gds);
+ this.setWeight(weight);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ */
+ public UndirectedWeightedBlueprintsNode(String str, GraphDataStructure gds) {
+ super(str.split(Weight.WeightDelimiter)[0], gds);
+ this.setWeight(gds.newNodeWeight(str.split(Weight.WeightDelimiter)[1]));
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param i the index
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public UndirectedWeightedBlueprintsNode(int i, GraphDataStructure gds, IGraph graph) {
+ super(i, gds, graph);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param i the index
+ * @param weight the weight
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public UndirectedWeightedBlueprintsNode(int i, Weight weight,
+ GraphDataStructure gds, IGraph graph) {
+ this(i, gds, graph);
+ this.setWeight(weight);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param str the str
+ * @param gds the gds
+ * @param graph the graph
+ */
+ public UndirectedWeightedBlueprintsNode(String str, GraphDataStructure gds,
+ IGraph graph) {
+ super(str.split(Weight.WeightDelimiter)[0], gds);
+ this.setWeight(gds.newNodeWeight(str.split(Weight.WeightDelimiter)[1]));
+ this.setGraph(graph);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param i the index
+ * @param gds the gds
+ * @param vertex the vertex
+ * @param graph the graph
+ */
+ public UndirectedWeightedBlueprintsNode(int i, GraphDataStructure gds,
+ Object gdbNodeId, IGraph graph) {
+ super(i, gds, gdbNodeId, graph);
+ }
+
+ /**
+ * Instantiates a new undirected weighted blueprints node.
+ *
+ * @param i the index
+ * @param weight the weight
+ * @param gds the gds
+ * @param vertex the vertex
+ * @param graph the graph
+ */
+ public UndirectedWeightedBlueprintsNode(int i, Weight weight,
+ GraphDataStructure gds, Object gdbNodeId, IGraph graph) {
+ this(i, gds, gdbNodeId, graph);
+ this.setWeight(weight);
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#getWeight()
+ */
+ @Override
+ public Weight getWeight() {
+ if (this.getGDBNode() == null)
+ return this.weight;
+
+ String weight = this.getGDBNode().getProperty("weight");
+ if (weight == null)
+ this.setWeight(this.weight);
+ return this.weight;
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.weights.IWeighted#setWeight(dna.graph.weights.Weight)
+ */
+ @Override
+ public void setWeight(Weight weight) {
+ this.weight = weight;
+ if (this.getGDBNode() == null)
+ return;
+ this.getGDBNode().setProperty("weight", weight.asString());
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.Node#asString()
+ */
+ @Override
+ public String asString() {
+ return super.asString() + Weight.WeightDelimiter
+ + this.getWeight().asString();
+ }
+
+ /* (non-Javadoc)
+ * @see dna.graph.nodes.UndirectedNode#toString()
+ */
+ public String toString() {
+ return super.toString() + " [" + this.getWeight().asString() + "]";
+ }
+
+}
diff --git a/src/dna/io/BatchReader.java b/src/dna/io/BatchReader.java
index bcc9a03f..85d9ba09 100644
--- a/src/dna/io/BatchReader.java
+++ b/src/dna/io/BatchReader.java
@@ -4,7 +4,7 @@
import java.util.HashMap;
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.updates.batch.Batch;
@@ -20,7 +20,7 @@
*/
public class BatchReader {
- public static Batch read(String dir, String filename, Graph g) {
+ public static Batch read(String dir, String filename, IGraph g) {
Reader reader = null;
try {
@@ -67,7 +67,7 @@ public static Batch read(String dir, String filename, Graph g) {
}
}
- protected static Update parseLine(String line, Graph g,
+ protected static Update parseLine(String line, IGraph g,
HashMap addedNodes) {
return Update.fromString(g.getGraphDatastructures(), g, line,
addedNodes);
diff --git a/src/dna/io/EdgeListGraphReader.java b/src/dna/io/EdgeListGraphReader.java
index 1e51c93e..aa52268a 100644
--- a/src/dna/io/EdgeListGraphReader.java
+++ b/src/dna/io/EdgeListGraphReader.java
@@ -3,14 +3,14 @@
import java.io.IOException;
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
public class EdgeListGraphReader {
- public static Graph read(String dir, String filename, String separator,
+ public static IGraph read(String dir, String filename, String separator,
GraphDataStructure gds) throws IOException {
HashMap mapping = new HashMap();
@@ -33,7 +33,7 @@ public static Graph read(String dir, String filename, String separator,
}
reader.close();
- Graph g = gds.newGraphInstance(filename, 0, nodes, edges);
+ IGraph g = gds.newGraphInstance(filename, 0, nodes, edges);
for (int i = 0; i < nodes; i++) {
g.addNode(gds.newNodeInstance(i));
}
diff --git a/src/dna/io/EdgeListGraphWriter.java b/src/dna/io/EdgeListGraphWriter.java
index 0143f161..1950fa08 100644
--- a/src/dna/io/EdgeListGraphWriter.java
+++ b/src/dna/io/EdgeListGraphWriter.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.UndirectedEdge;
@@ -13,7 +13,7 @@ public enum InfoType {
NONE, N, NM
}
- public static boolean write(Graph g, String dir, String filename,
+ public static boolean write(IGraph g, String dir, String filename,
String separator, InfoType info, boolean addInverseEdge,
boolean incIndex, String prefix, String suffix) {
Writer writer = null;
diff --git a/src/dna/io/GraphReader.java b/src/dna/io/GraphReader.java
index 01499aad..abdc94ac 100644
--- a/src/dna/io/GraphReader.java
+++ b/src/dna/io/GraphReader.java
@@ -2,18 +2,18 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
public class GraphReader {
- public static Graph read(String dir, String filename)
+ public static IGraph read(String dir, String filename)
throws ClassNotFoundException, IOException {
return read(dir, filename, null);
}
- public static Graph read(String dir, String filename, GraphDataStructure ds)
+ public static IGraph read(String dir, String filename, GraphDataStructure ds)
throws IOException {
Reader reader = new Reader(dir, filename);
@@ -36,7 +36,7 @@ public static Graph read(String dir, String filename, GraphDataStructure ds)
reader.readKeyword(GraphWriter.timestampKeyword);
long timestamp = reader.readLong();
- Graph g = ds.newGraphInstance(name, timestamp, nodes, edges);
+ IGraph g = ds.newGraphInstance(name, timestamp, nodes, edges);
reader.readKeyword(GraphWriter.nodesListKeyword);
String line = null;
diff --git a/src/dna/io/GraphWriter.java b/src/dna/io/GraphWriter.java
index 4d2bd17c..bae7f8fb 100644
--- a/src/dna/io/GraphWriter.java
+++ b/src/dna/io/GraphWriter.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
public class GraphWriter {
@@ -18,7 +18,7 @@ public class GraphWriter {
public static final String nodesListKeyword = "List of Nodes";
public static final String edgesListKeyword = "List of Edges";
- public static boolean write(Graph g, String dir, String filename) {
+ public static boolean write(IGraph g, String dir, String filename) {
Writer writer = null;
try {
writer = new Writer(dir, filename);
diff --git a/src/dna/io/LegacyBatchReader.java b/src/dna/io/LegacyBatchReader.java
index 2c4ef990..2a2be1bd 100644
--- a/src/dna/io/LegacyBatchReader.java
+++ b/src/dna/io/LegacyBatchReader.java
@@ -4,7 +4,7 @@
import java.util.HashMap;
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.graph.weights.IWeightedEdge;
@@ -37,7 +37,7 @@ public static enum LegacyUpdateType {
public static final String weightDelimiter = "--";
- public static Batch read(String dir, String filename, Graph g) {
+ public static Batch read(String dir, String filename, IGraph g) {
Reader reader = null;
try {
@@ -84,7 +84,7 @@ public static Batch read(String dir, String filename, Graph g) {
}
}
- protected static Update parseLine(String line, Graph g,
+ protected static Update parseLine(String line, IGraph g,
HashMap addedNodes) {
String[] temp = line.split(LegacyBatchReader.typeDelimiter);
LegacyUpdateType type = LegacyUpdateType.valueOf(temp[0]);
diff --git a/src/dna/io/SNAPGraphReader.java b/src/dna/io/SNAPGraphReader.java
index e033161d..18a5ec5b 100644
--- a/src/dna/io/SNAPGraphReader.java
+++ b/src/dna/io/SNAPGraphReader.java
@@ -5,7 +5,7 @@
import com.sun.media.sound.InvalidFormatException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.DArray;
import dna.graph.datastructures.DArrayList;
import dna.graph.datastructures.DLinkedHashMultimap;
@@ -51,7 +51,7 @@ public class SNAPGraphReader {
* @throws IOException
* in case the file does not exist
*/
- public static Graph read(String dir, String filename) throws IOException {
+ public static IGraph read(String dir, String filename) throws IOException {
return read(dir, filename, null);
}
@@ -67,7 +67,7 @@ public static Graph read(String dir, String filename) throws IOException {
* @throws IOException
* in case the file does not exist
*/
- public static Graph readUndirected(String dir, String filename)
+ public static IGraph readUndirected(String dir, String filename)
throws IOException {
return read(dir, filename, undirectedGDSSetup);
}
@@ -86,7 +86,7 @@ public static Graph readUndirected(String dir, String filename)
* @throws IOException
* in case the file does not exist
*/
- public static Graph read(String dir, String filename, GraphDataStructure ds)
+ public static IGraph read(String dir, String filename, GraphDataStructure ds)
throws IOException {
HashMap map = new HashMap();
@@ -140,7 +140,7 @@ public static Graph read(String dir, String filename, GraphDataStructure ds)
int edgeCount = Integer.parseInt(nodeAndEdgeCount);
// Creates the graph
- Graph g = ds.newGraphInstance(name, 0, nodeCount, edgeCount);
+ IGraph g = ds.newGraphInstance(name, 0, nodeCount, edgeCount);
// Reads and adds the edges
String line = reader.readString();
diff --git a/src/dna/metrics/IMetric.java b/src/dna/metrics/IMetric.java
index 6340893b..4954f449 100644
--- a/src/dna/metrics/IMetric.java
+++ b/src/dna/metrics/IMetric.java
@@ -1,6 +1,6 @@
package dna.metrics;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.series.data.MetricData;
import dna.series.data.Value;
import dna.series.data.distr.Distr;
@@ -14,9 +14,9 @@ public static enum MetricType {
exact, heuristic, quality, unknown
}
- public Graph getGraph();
+ public IGraph getGraph();
- public void setGraph(Graph g);
+ public void setGraph(IGraph g);
public MetricData getData();
@@ -85,7 +85,7 @@ public static enum MetricType {
* graph to check for applicability
* @return true, if the metric can be applied to the given graph
*/
- public boolean isApplicable(Graph g);
+ public boolean isApplicable(IGraph g);
/**
*
diff --git a/src/dna/metrics/Metric.java b/src/dna/metrics/Metric.java
index 13e525af..1842c995 100644
--- a/src/dna/metrics/Metric.java
+++ b/src/dna/metrics/Metric.java
@@ -2,8 +2,8 @@
import com.google.common.collect.Iterables;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.graph.weights.ITypedWeight;
import dna.graph.weights.IWeightedNode;
@@ -80,13 +80,13 @@ protected static Parameter[] combine(Parameter[] p1, Parameter[] p2) {
return p;
}
- protected Graph g;
+ protected IGraph g;
- public Graph getGraph() {
+ public IGraph getGraph() {
return this.g;
}
- public void setGraph(Graph g) {
+ public void setGraph(IGraph g) {
this.g = g;
if (this.nodeTypes.length > 0
&& this.g.getGraphDatastructures().isNodeType(
diff --git a/src/dna/metrics/MetricNotApplicableException.java b/src/dna/metrics/MetricNotApplicableException.java
index bd4c7657..a95d1d10 100644
--- a/src/dna/metrics/MetricNotApplicableException.java
+++ b/src/dna/metrics/MetricNotApplicableException.java
@@ -1,13 +1,13 @@
package dna.metrics;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
public class MetricNotApplicableException extends Exception {
private static final long serialVersionUID = 7635116747945152349L;
- public MetricNotApplicableException(IMetric m, Graph g) {
+ public MetricNotApplicableException(IMetric m, IGraph g) {
super("metric " + m.getName() + " is not applicable to graph "
+ g.getName());
}
diff --git a/src/dna/metrics/assortativity/Assortativity.java b/src/dna/metrics/assortativity/Assortativity.java
index 9d174803..0021d76b 100644
--- a/src/dna/metrics/assortativity/Assortativity.java
+++ b/src/dna/metrics/assortativity/Assortativity.java
@@ -1,7 +1,7 @@
package dna.metrics.assortativity;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.DirectedWeightedEdge;
import dna.graph.edges.UndirectedEdge;
@@ -350,7 +350,7 @@ public boolean isApplicable(Batch b) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/centrality/BetweennessCentrality.java b/src/dna/metrics/centrality/BetweennessCentrality.java
index 15a9ca37..ed0162c6 100644
--- a/src/dna/metrics/centrality/BetweennessCentrality.java
+++ b/src/dna/metrics/centrality/BetweennessCentrality.java
@@ -3,8 +3,8 @@
import java.util.HashMap;
import java.util.Map.Entry;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.metrics.IMetric;
import dna.metrics.Metric;
@@ -108,7 +108,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/clustering/DirectedClusteringCoefficient.java b/src/dna/metrics/clustering/DirectedClusteringCoefficient.java
index c57c70be..3defaa81 100644
--- a/src/dna/metrics/clustering/DirectedClusteringCoefficient.java
+++ b/src/dna/metrics/clustering/DirectedClusteringCoefficient.java
@@ -1,7 +1,7 @@
package dna.metrics.clustering;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.DirectedNode;
import dna.series.data.lists.LongList;
import dna.series.data.nodevaluelists.NodeValueList;
@@ -22,7 +22,7 @@ public DirectedClusteringCoefficient(String name, String[] nodeTypes,
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(DirectedNode.class);
}
diff --git a/src/dna/metrics/clustering/UndirectedClusteringCoefficient.java b/src/dna/metrics/clustering/UndirectedClusteringCoefficient.java
index 7e58278e..99409b9a 100644
--- a/src/dna/metrics/clustering/UndirectedClusteringCoefficient.java
+++ b/src/dna/metrics/clustering/UndirectedClusteringCoefficient.java
@@ -1,7 +1,7 @@
package dna.metrics.clustering;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.UndirectedEdge;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.UndirectedNode;
@@ -24,7 +24,7 @@ public UndirectedClusteringCoefficient(String name, String[] nodeTypes,
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/clustering/local/DirectedLocalClusteringCoefficient.java b/src/dna/metrics/clustering/local/DirectedLocalClusteringCoefficient.java
index 4d47a46f..6e09c108 100644
--- a/src/dna/metrics/clustering/local/DirectedLocalClusteringCoefficient.java
+++ b/src/dna/metrics/clustering/local/DirectedLocalClusteringCoefficient.java
@@ -1,7 +1,7 @@
package dna.metrics.clustering.local;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.DirectedNode;
import dna.metrics.IMetric;
import dna.updates.batch.Batch;
@@ -50,7 +50,7 @@ protected long computeClosed(int index) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(DirectedNode.class);
}
diff --git a/src/dna/metrics/clustering/local/UndirectedLocalClusteringCoefficient.java b/src/dna/metrics/clustering/local/UndirectedLocalClusteringCoefficient.java
index 27c6acba..4ab44c75 100644
--- a/src/dna/metrics/clustering/local/UndirectedLocalClusteringCoefficient.java
+++ b/src/dna/metrics/clustering/local/UndirectedLocalClusteringCoefficient.java
@@ -1,7 +1,7 @@
package dna.metrics.clustering.local;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.UndirectedEdge;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.UndirectedNode;
@@ -81,7 +81,7 @@ protected long computeClosedUndirected(int index) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/connectivity/StrongConnectivity.java b/src/dna/metrics/connectivity/StrongConnectivity.java
index 3af8a8de..6b22813c 100644
--- a/src/dna/metrics/connectivity/StrongConnectivity.java
+++ b/src/dna/metrics/connectivity/StrongConnectivity.java
@@ -4,8 +4,8 @@
import java.util.Map;
import java.util.Stack;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedEdge;
import dna.graph.nodes.DirectedNode;
import dna.metrics.IMetric;
@@ -251,7 +251,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.isDirected();
}
diff --git a/src/dna/metrics/connectivity/WeakConnectivity.java b/src/dna/metrics/connectivity/WeakConnectivity.java
index e2b3ca03..0faf162e 100644
--- a/src/dna/metrics/connectivity/WeakConnectivity.java
+++ b/src/dna/metrics/connectivity/WeakConnectivity.java
@@ -4,8 +4,8 @@
import java.util.LinkedList;
import java.util.Queue;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.metrics.IMetric;
@@ -158,7 +158,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/degree/DegreeDistribution.java b/src/dna/metrics/degree/DegreeDistribution.java
index e1ecff43..484a3b5e 100644
--- a/src/dna/metrics/degree/DegreeDistribution.java
+++ b/src/dna/metrics/degree/DegreeDistribution.java
@@ -1,6 +1,6 @@
package dna.metrics.degree;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.UndirectedNode;
@@ -90,7 +90,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/motifs/DirectedMotifs.java b/src/dna/metrics/motifs/DirectedMotifs.java
index a084509b..5502ebd5 100644
--- a/src/dna/metrics/motifs/DirectedMotifs.java
+++ b/src/dna/metrics/motifs/DirectedMotifs.java
@@ -2,8 +2,8 @@
import java.util.HashSet;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedEdge;
import dna.graph.nodes.DirectedNode;
import dna.metrics.IMetric;
@@ -80,7 +80,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(DirectedNode.class);
}
diff --git a/src/dna/metrics/motifs/UndirectedMotifs.java b/src/dna/metrics/motifs/UndirectedMotifs.java
index d7cb90ba..8812f96a 100644
--- a/src/dna/metrics/motifs/UndirectedMotifs.java
+++ b/src/dna/metrics/motifs/UndirectedMotifs.java
@@ -3,8 +3,8 @@
import java.util.ArrayList;
import java.util.Arrays;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.UndirectedEdge;
import dna.graph.nodes.UndirectedNode;
import dna.metrics.IMetric;
@@ -73,7 +73,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(UndirectedNode.class);
}
diff --git a/src/dna/metrics/motifs/UndirectedMotifsPerNodes.java b/src/dna/metrics/motifs/UndirectedMotifsPerNodes.java
index 70dc6c2e..44e6c424 100644
--- a/src/dna/metrics/motifs/UndirectedMotifsPerNodes.java
+++ b/src/dna/metrics/motifs/UndirectedMotifsPerNodes.java
@@ -5,7 +5,7 @@
import java.util.Comparator;
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.UndirectedEdge;
import dna.graph.nodes.UndirectedNode;
@@ -103,7 +103,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(UndirectedNode.class);
}
diff --git a/src/dna/metrics/parallelization/ParallelMetric.java b/src/dna/metrics/parallelization/ParallelMetric.java
index ce7e81c7..7c06ddfa 100644
--- a/src/dna/metrics/parallelization/ParallelMetric.java
+++ b/src/dna/metrics/parallelization/ParallelMetric.java
@@ -1,6 +1,6 @@
package dna.metrics.parallelization;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.IMetric;
import dna.metrics.Metric;
import dna.metrics.algorithms.IAfterBatch;
@@ -152,7 +152,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return this.metric.isApplicable(g);
}
@@ -162,7 +162,7 @@ public boolean isApplicable(Batch b) {
}
@Override
- public void setGraph(Graph g) {
+ public void setGraph(IGraph g) {
super.setGraph(g);
this.partitioningScheme.init(g, this.metric);
this.partitionRuntimes = new long[this.partitioningScheme.partitions.length];
diff --git a/src/dna/metrics/parallelization/collation/Collation.java b/src/dna/metrics/parallelization/collation/Collation.java
index aefc1c52..f4432206 100644
--- a/src/dna/metrics/parallelization/collation/Collation.java
+++ b/src/dna/metrics/parallelization/collation/Collation.java
@@ -1,6 +1,6 @@
package dna.metrics.parallelization.collation;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.Metric;
import dna.metrics.parallelization.partitioning.Partition;
import dna.series.data.Value;
@@ -56,7 +56,7 @@ public NodeNodeValueList[] getNodeNodeValueLists() {
return this.metric.getNodeNodeValueLists();
}
- public abstract boolean collate(Graph g, Partition[] partitions);
+ public abstract boolean collate(IGraph g, Partition[] partitions);
public abstract boolean isCollatable(Metric m);
diff --git a/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationNonOverlapping.java b/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationNonOverlapping.java
index 773b5552..dcc78fe9 100644
--- a/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationNonOverlapping.java
+++ b/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationNonOverlapping.java
@@ -1,6 +1,6 @@
package dna.metrics.parallelization.collation.clustering;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -21,7 +21,7 @@ public UndirectedClusteringCoefficientCollationNonOverlapping() {
}
@Override
- public boolean collate(Graph g, Partition[] partitions) {
+ public boolean collate(IGraph g, Partition[] partitions) {
this.metric.localCC = new NodeValueList("localCC",
g.getMaxNodeIndex() + 1);
this.metric.nodePotentialCount = new LongList(g.getMaxNodeIndex() + 1);
diff --git a/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationOverlapping.java b/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationOverlapping.java
index cb2d5a87..8137a05f 100644
--- a/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationOverlapping.java
+++ b/src/dna/metrics/parallelization/collation/clustering/UndirectedClusteringCoefficientCollationOverlapping.java
@@ -1,6 +1,6 @@
package dna.metrics.parallelization.collation.clustering;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.metrics.Metric;
import dna.metrics.clustering.UndirectedClusteringCoefficient;
@@ -17,7 +17,7 @@ public UndirectedClusteringCoefficientCollationOverlapping() {
}
@Override
- public boolean collate(Graph g, Partition[] partitions) {
+ public boolean collate(IGraph g, Partition[] partitions) {
this.metric.triangleCount = 0;
this.metric.triangleCount = 0;
this.metric.potentialCount = 0;
diff --git a/src/dna/metrics/parallelization/partitioning/NodeCutPartition.java b/src/dna/metrics/parallelization/partitioning/NodeCutPartition.java
index b9138b04..d2dde195 100644
--- a/src/dna/metrics/parallelization/partitioning/NodeCutPartition.java
+++ b/src/dna/metrics/parallelization/partitioning/NodeCutPartition.java
@@ -5,8 +5,8 @@
import java.util.List;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -50,19 +50,20 @@ public NodeCutPartition() {
super();
}
- public void init(Graph g, List nodes, Metric m, Set cutNodes,
+ public void init(IGraph g, List nodes, Metric m, Set cutNodes,
Set cutEdges) {
super.init(g, nodes, m);
this.cutNodes = cutNodes;
this.cutEdges = cutEdges;
}
+ @Override
public String toString() {
return "NodeCutPartition: " + g.toString() + " @ " + cutNodes.size()
+ " / " + cutEdges.size();
}
- public static NodeCutPartition[] getPartitions(Graph g,
+ public static NodeCutPartition[] getPartitions(IGraph g,
List> nodesList, Metric m,
HashMap partitionMap) {
NodeCutPartition[] p = new NodeCutPartition[nodesList.size()];
@@ -102,9 +103,9 @@ public static NodeCutPartition[] getPartitions(Graph g,
return p;
}
- protected static void fill(NodeCutPartition p, String name, Graph g,
+ protected static void fill(NodeCutPartition p, String name, IGraph g,
List nodes, Metric m, Set globalCut) {
- Graph gp = g.getGraphDatastructures().newGraphInstance(name,
+ IGraph gp = g.getGraphDatastructures().newGraphInstance(name,
g.getTimestamp(), nodes.size(),
nodes.size() == 0 ? 0 : g.getEdgeCount() / nodes.size());
GraphDataStructure gds = gp.getGraphDatastructures();
diff --git a/src/dna/metrics/parallelization/partitioning/NonOverlappingPartition.java b/src/dna/metrics/parallelization/partitioning/NonOverlappingPartition.java
index e75ad25b..01154500 100644
--- a/src/dna/metrics/parallelization/partitioning/NonOverlappingPartition.java
+++ b/src/dna/metrics/parallelization/partitioning/NonOverlappingPartition.java
@@ -5,8 +5,8 @@
import java.util.List;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -40,18 +40,19 @@ public Set getExternalEdges() {
return externalEdges;
}
- public NonOverlappingPartition(Graph g, List nodes, Metric m,
+ public NonOverlappingPartition(IGraph g, List nodes, Metric m,
Set connections) {
super(g, nodes, m);
this.externalEdges = connections;
}
+ @Override
public String toString() {
return "NonOverlappingPartition: " + g.toString() + " @ "
+ externalEdges.size();
}
- public static NonOverlappingPartition[] getPartitions(Graph g,
+ public static NonOverlappingPartition[] getPartitions(IGraph g,
List> nodesList, Metric m,
HashMap partitionMap) {
NonOverlappingPartition[] p = new NonOverlappingPartition[nodesList
@@ -67,9 +68,9 @@ public static NonOverlappingPartition[] getPartitions(Graph g,
return p;
}
- protected static NonOverlappingPartition getPartition(String name, Graph g,
+ protected static NonOverlappingPartition getPartition(String name, IGraph g,
List nodes, Metric m) {
- Graph gp = g.getGraphDatastructures().newGraphInstance(name,
+ IGraph gp = g.getGraphDatastructures().newGraphInstance(name,
g.getTimestamp(), nodes.size(),
nodes.size() == 0 ? 0 : g.getEdgeCount() / nodes.size());
GraphDataStructure gds = gp.getGraphDatastructures();
diff --git a/src/dna/metrics/parallelization/partitioning/OverlappingPartition.java b/src/dna/metrics/parallelization/partitioning/OverlappingPartition.java
index e1c4d6a8..efb4ff3e 100644
--- a/src/dna/metrics/parallelization/partitioning/OverlappingPartition.java
+++ b/src/dna/metrics/parallelization/partitioning/OverlappingPartition.java
@@ -5,8 +5,8 @@
import java.util.List;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -42,7 +42,7 @@ public Set getAuxiliaryNodes() {
return this.auxiliaryNodes;
}
- public OverlappingPartition(Graph g, List nodes, Metric m,
+ public OverlappingPartition(IGraph g, List nodes, Metric m,
Set auxiliaryNodes, Set auxiliaryEdges) {
super(g, nodes, m);
this.auxiliaryNodes = auxiliaryNodes;
@@ -53,12 +53,13 @@ public boolean addOverlap(Node n) {
return this.auxiliaryNodes.add(n);
}
+ @Override
public String toString() {
return "OverlappingPartition: " + g.toString() + " @ "
+ auxiliaryNodes.size() + " / " + auxiliaryEdges.size();
}
- public static OverlappingPartition[] getPartitions(Graph g,
+ public static OverlappingPartition[] getPartitions(IGraph g,
List> nodesList, Metric m,
HashMap partitionMap) {
OverlappingPartition[] p = new OverlappingPartition[nodesList.size()];
@@ -73,9 +74,9 @@ public static OverlappingPartition[] getPartitions(Graph g,
return p;
}
- protected static OverlappingPartition getPartition(String name, Graph g,
+ protected static OverlappingPartition getPartition(String name, IGraph g,
List nodes, Metric m) {
- Graph gp = g.getGraphDatastructures().newGraphInstance(name,
+ IGraph gp = g.getGraphDatastructures().newGraphInstance(name,
g.getTimestamp(), nodes.size(),
nodes.size() == 0 ? 0 : g.getEdgeCount() / nodes.size());
GraphDataStructure gds = gp.getGraphDatastructures();
diff --git a/src/dna/metrics/parallelization/partitioning/Partition.java b/src/dna/metrics/parallelization/partitioning/Partition.java
index 5032ec4d..6dab8f14 100644
--- a/src/dna/metrics/parallelization/partitioning/Partition.java
+++ b/src/dna/metrics/parallelization/partitioning/Partition.java
@@ -5,7 +5,7 @@
import java.util.List;
import java.util.Set;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.metrics.Metric;
@@ -44,7 +44,7 @@
*/
public abstract class Partition {
- protected Graph g;
+ protected IGraph g;
protected List nodes;
protected Set nodeSet;
@@ -60,11 +60,11 @@ public Timer getTimer() {
public Partition() {
}
- public Partition(Graph g, List nodes, Metric m) {
+ public Partition(IGraph g, List nodes, Metric m) {
this.init(g, nodes, m);
}
- public void init(Graph g, List nodes, Metric m) {
+ public void init(IGraph g, List nodes, Metric m) {
this.g = g;
this.nodes = nodes;
this.m = m;
@@ -73,7 +73,7 @@ public void init(Graph g, List nodes, Metric m) {
this.t = new Timer();
}
- public Graph getGraph() {
+ public IGraph getGraph() {
return this.g;
}
diff --git a/src/dna/metrics/parallelization/partitioning/schemes/BFSPartitioning.java b/src/dna/metrics/parallelization/partitioning/schemes/BFSPartitioning.java
index a28a6185..b9792284 100644
--- a/src/dna/metrics/parallelization/partitioning/schemes/BFSPartitioning.java
+++ b/src/dna/metrics/parallelization/partitioning/schemes/BFSPartitioning.java
@@ -6,7 +6,7 @@
import java.util.List;
import java.util.Queue;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -18,7 +18,7 @@ public BFSPartitioning(PartitioningType partitioningType, int partitionCount) {
}
@Override
- public List> getPartitioning(Graph g) {
+ public List> getPartitioning(IGraph g) {
HashSet visited = new HashSet(g.getNodeCount());
List orderedNodes = new ArrayList(g.getNodeCount());
diff --git a/src/dna/metrics/parallelization/partitioning/schemes/DFSPartitioning.java b/src/dna/metrics/parallelization/partitioning/schemes/DFSPartitioning.java
index 962a16e1..6186ba27 100644
--- a/src/dna/metrics/parallelization/partitioning/schemes/DFSPartitioning.java
+++ b/src/dna/metrics/parallelization/partitioning/schemes/DFSPartitioning.java
@@ -5,7 +5,7 @@
import java.util.LinkedList;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -17,7 +17,7 @@ public DFSPartitioning(PartitioningType partitioningType, int partitionCount) {
}
@Override
- public List> getPartitioning(Graph g) {
+ public List> getPartitioning(IGraph g) {
// int costPerBatch = (int) Math.ceil((double) g.getNodeCount()
// / (double) this.partitionCount);
diff --git a/src/dna/metrics/parallelization/partitioning/schemes/EqualSizePartitioning.java b/src/dna/metrics/parallelization/partitioning/schemes/EqualSizePartitioning.java
index 6ef3c920..df80b7d8 100644
--- a/src/dna/metrics/parallelization/partitioning/schemes/EqualSizePartitioning.java
+++ b/src/dna/metrics/parallelization/partitioning/schemes/EqualSizePartitioning.java
@@ -2,7 +2,7 @@
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
public class EqualSizePartitioning extends PartitioningScheme {
@@ -13,7 +13,7 @@ public EqualSizePartitioning(PartitioningType partitioningType,
}
@Override
- public List> getPartitioning(Graph g) {
+ public List> getPartitioning(IGraph g) {
int partitionSize = (int) Math.ceil((double) g.getNodeCount()
/ (double) this.partitionCount);
List> partitioning = this.createNewPartitioning();
diff --git a/src/dna/metrics/parallelization/partitioning/schemes/LPAPartitioning.java b/src/dna/metrics/parallelization/partitioning/schemes/LPAPartitioning.java
index 7bd8d43e..feeacc2d 100644
--- a/src/dna/metrics/parallelization/partitioning/schemes/LPAPartitioning.java
+++ b/src/dna/metrics/parallelization/partitioning/schemes/LPAPartitioning.java
@@ -7,7 +7,7 @@
import java.util.List;
import java.util.Map.Entry;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -57,7 +57,7 @@ public int getRounds() {
}
@Override
- public List> getPartitioning(Graph g) {
+ public List> getPartitioning(IGraph g) {
currentLabels = new int[g.getMaxNodeIndex() + 1];
newLabels = new int[g.getMaxNodeIndex() + 1];
for (int i = 0; i < currentLabels.length; i++) {
@@ -136,7 +136,7 @@ public int compare(List a1, List a2) {
return partitions;
}
- protected void nextRound(Graph g) {
+ protected void nextRound(IGraph g) {
changes = 0;
for (IElement n_ : g.getNodes()) {
changes += this.computeLabel(g, (Node) n_) ? 1 : 0;
@@ -145,7 +145,7 @@ protected void nextRound(Graph g) {
newLabels = new int[g.getMaxNodeIndex() + 1];
}
- protected boolean computeLabel(Graph g, Node n) {
+ protected boolean computeLabel(IGraph g, Node n) {
if (n.getDegree() == 0) {
newLabels[n.getIndex()] = currentLabels[n.getIndex()];
return false;
diff --git a/src/dna/metrics/parallelization/partitioning/schemes/PartitioningScheme.java b/src/dna/metrics/parallelization/partitioning/schemes/PartitioningScheme.java
index f8d91861..4d520bfd 100644
--- a/src/dna/metrics/parallelization/partitioning/schemes/PartitioningScheme.java
+++ b/src/dna/metrics/parallelization/partitioning/schemes/PartitioningScheme.java
@@ -4,7 +4,7 @@
import java.util.HashMap;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.metrics.Metric;
import dna.metrics.parallelization.collation.PartitionedMetric;
@@ -74,7 +74,7 @@ public PartitioningScheme(String name, PartitioningType partitioningType,
* @param m
* metric (a clone is assigned to each partition)
*/
- public void init(Graph g, Metric m) {
+ public void init(IGraph g, Metric m) {
List> p = this.getPartitioning(g);
this.partitionMap = new HashMap();
// this.partitions = new Partition[p.size()];
@@ -123,21 +123,7 @@ public void init(Graph g, Metric m) {
}
}
- // protected Partition createPartition(String name, Graph g, List
- // nodes,
- // Metric m) {
- // switch (partitioningType) {
- // case NON_OVERLAPPING:
- // return NonOverlappingPartition.getPartition(name, g, nodes, m);
- // case OVERLAPPING:
- // return OverlappingPartition.getPartition(name, g, nodes, m);
- // default:
- // throw new IllegalArgumentException("unknown partitioning type: "
- // + partitioningType);
- // }
- // }
-
- public abstract List> getPartitioning(Graph g);
+ public abstract List> getPartitioning(IGraph g);
public PartitioningType getPartitioningType() {
return this.partitioningType;
diff --git a/src/dna/metrics/parallelization/partitioning/schemes/RandomPartitioning.java b/src/dna/metrics/parallelization/partitioning/schemes/RandomPartitioning.java
index 45ee0e08..4a780b9a 100644
--- a/src/dna/metrics/parallelization/partitioning/schemes/RandomPartitioning.java
+++ b/src/dna/metrics/parallelization/partitioning/schemes/RandomPartitioning.java
@@ -4,7 +4,7 @@
import java.util.LinkedList;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.nodes.Node;
import dna.util.Rand;
@@ -17,7 +17,7 @@ public RandomPartitioning(PartitioningType partitioningType,
}
@Override
- public List> getPartitioning(Graph g) {
+ public List> getPartitioning(IGraph g) {
ArrayList> partitioning = new ArrayList>(
this.partitionCount);
diff --git a/src/dna/metrics/paths/DoubleWeightedAllPairsShortestPaths.java b/src/dna/metrics/paths/DoubleWeightedAllPairsShortestPaths.java
index 19d91f80..8f21d0a4 100644
--- a/src/dna/metrics/paths/DoubleWeightedAllPairsShortestPaths.java
+++ b/src/dna/metrics/paths/DoubleWeightedAllPairsShortestPaths.java
@@ -1,6 +1,6 @@
package dna.metrics.paths;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.weights.IWeightedEdge;
import dna.graph.weights.doubleW.DoubleWeight;
import dna.metrics.IMetric;
@@ -22,7 +22,7 @@ public boolean isComparableTo(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isEdgeType(IWeightedEdge.class)
&& g.getGraphDatastructures().isEdgeWeightType(
DoubleWeight.class);
diff --git a/src/dna/metrics/paths/IntWeightedAllPairsShortestPaths.java b/src/dna/metrics/paths/IntWeightedAllPairsShortestPaths.java
index ee099110..ae829bb4 100644
--- a/src/dna/metrics/paths/IntWeightedAllPairsShortestPaths.java
+++ b/src/dna/metrics/paths/IntWeightedAllPairsShortestPaths.java
@@ -1,6 +1,6 @@
package dna.metrics.paths;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.weights.IWeightedEdge;
import dna.graph.weights.intW.IntWeight;
import dna.metrics.IMetric;
@@ -19,7 +19,7 @@ public boolean isComparableTo(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isEdgeType(IWeightedEdge.class)
&& g.getGraphDatastructures().isEdgeWeightType(IntWeight.class);
}
diff --git a/src/dna/metrics/paths/UnweightedAllPairsShortestPaths.java b/src/dna/metrics/paths/UnweightedAllPairsShortestPaths.java
index 7d42cd88..ea5c1901 100644
--- a/src/dna/metrics/paths/UnweightedAllPairsShortestPaths.java
+++ b/src/dna/metrics/paths/UnweightedAllPairsShortestPaths.java
@@ -2,8 +2,8 @@
import java.util.LinkedList;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.UndirectedEdge;
import dna.graph.nodes.DirectedNode;
@@ -29,7 +29,7 @@ public boolean isComparableTo(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/paths/UnweightedSingleSourceShortestPaths.java b/src/dna/metrics/paths/UnweightedSingleSourceShortestPaths.java
index 716858c4..8ff16a56 100644
--- a/src/dna/metrics/paths/UnweightedSingleSourceShortestPaths.java
+++ b/src/dna/metrics/paths/UnweightedSingleSourceShortestPaths.java
@@ -1,6 +1,6 @@
package dna.metrics.paths;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.IMetric;
import dna.updates.batch.Batch;
@@ -17,7 +17,7 @@ public boolean isComparableTo(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/richClub/RichClubConnectivityByDegree.java b/src/dna/metrics/richClub/RichClubConnectivityByDegree.java
index 6d0fd2d5..b7427461 100644
--- a/src/dna/metrics/richClub/RichClubConnectivityByDegree.java
+++ b/src/dna/metrics/richClub/RichClubConnectivityByDegree.java
@@ -1,7 +1,7 @@
package dna.metrics.richClub;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.metrics.IMetric;
import dna.metrics.Metric;
@@ -119,7 +119,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/sampling/Extent.java b/src/dna/metrics/sampling/Extent.java
index d69e3146..ad011e1e 100644
--- a/src/dna/metrics/sampling/Extent.java
+++ b/src/dna/metrics/sampling/Extent.java
@@ -1,6 +1,6 @@
package dna.metrics.sampling;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.IMetric;
import dna.metrics.Metric;
import dna.series.data.Value;
@@ -80,7 +80,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/sampling/SamplingModularity.java b/src/dna/metrics/sampling/SamplingModularity.java
index 962db96a..fa88cb6a 100644
--- a/src/dna/metrics/sampling/SamplingModularity.java
+++ b/src/dna/metrics/sampling/SamplingModularity.java
@@ -1,7 +1,7 @@
package dna.metrics.sampling;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.Node;
import dna.graph.nodes.UndirectedNode;
@@ -27,7 +27,7 @@
public abstract class SamplingModularity extends Metric {
private boolean directed;
- private Graph graph;
+ private IGraph graph;
protected int edgesInSample;
protected int edgesInGraph;
// Sum of the degree that the nodes of the sample have in the original graph
@@ -36,7 +36,7 @@ public abstract class SamplingModularity extends Metric {
// degreeSum - 2x edgesInGraph computes the degree amount of edges between
// the sample and the original graph
- public SamplingModularity(String name, Graph graph) {
+ public SamplingModularity(String name, IGraph graph) {
super(name, MetricType.exact);
this.graph = graph;
if (DirectedNode.class.isAssignableFrom(this.graph
@@ -93,7 +93,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/sampling/SamplingModularityB.java b/src/dna/metrics/sampling/SamplingModularityB.java
index 0ffa6b50..4e03ab24 100644
--- a/src/dna/metrics/sampling/SamplingModularityB.java
+++ b/src/dna/metrics/sampling/SamplingModularityB.java
@@ -1,6 +1,6 @@
package dna.metrics.sampling;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.metrics.algorithms.IAfterBatch;
import dna.updates.batch.Batch;
@@ -19,7 +19,7 @@
public class SamplingModularityB extends SamplingModularity implements
IAfterBatch {
- public SamplingModularityB(Graph graph) {
+ public SamplingModularityB(IGraph graph) {
super("SamplingModularityB", graph);
}
diff --git a/src/dna/metrics/sampling/SamplingModularityR.java b/src/dna/metrics/sampling/SamplingModularityR.java
index cdad7ae7..a4d01166 100644
--- a/src/dna/metrics/sampling/SamplingModularityR.java
+++ b/src/dna/metrics/sampling/SamplingModularityR.java
@@ -1,6 +1,6 @@
package dna.metrics.sampling;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.algorithms.IRecomputation;
/**
@@ -16,7 +16,7 @@
public class SamplingModularityR extends SamplingModularity implements
IRecomputation {
- public SamplingModularityR(Graph graph) {
+ public SamplingModularityR(IGraph graph) {
super("SamplingModularityR", graph);
}
diff --git a/src/dna/metrics/similarityMeasures/Measures.java b/src/dna/metrics/similarityMeasures/Measures.java
index 0f7826eb..93872bbf 100644
--- a/src/dna/metrics/similarityMeasures/Measures.java
+++ b/src/dna/metrics/similarityMeasures/Measures.java
@@ -6,8 +6,8 @@
import java.util.Map.Entry;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.DirectedWeightedEdge;
import dna.graph.edges.UndirectedEdge;
@@ -555,7 +555,7 @@ public boolean isApplicable(Batch b) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/similarityMeasures/jaccard/Jaccard.java b/src/dna/metrics/similarityMeasures/jaccard/Jaccard.java
index be7d2fb7..31989be5 100644
--- a/src/dna/metrics/similarityMeasures/jaccard/Jaccard.java
+++ b/src/dna/metrics/similarityMeasures/jaccard/Jaccard.java
@@ -6,8 +6,8 @@
import java.util.Map.Entry;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedWeightedEdge;
import dna.graph.edges.UndirectedWeightedEdge;
import dna.graph.nodes.DirectedNode;
@@ -438,7 +438,7 @@ public boolean isApplicable(Batch b) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/similarityMeasures/matching/Matching.java b/src/dna/metrics/similarityMeasures/matching/Matching.java
index 0e27992e..71e5d71c 100644
--- a/src/dna/metrics/similarityMeasures/matching/Matching.java
+++ b/src/dna/metrics/similarityMeasures/matching/Matching.java
@@ -5,8 +5,8 @@
import java.util.Map;
import java.util.Map.Entry;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.DirectedWeightedEdge;
import dna.graph.edges.UndirectedEdge;
@@ -700,7 +700,7 @@ public boolean isApplicable(Batch b) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/streaM_k/AdjacencyMatrix_k.java b/src/dna/metrics/streaM_k/AdjacencyMatrix_k.java
index caab202d..3b9b9f64 100644
--- a/src/dna/metrics/streaM_k/AdjacencyMatrix_k.java
+++ b/src/dna/metrics/streaM_k/AdjacencyMatrix_k.java
@@ -1,6 +1,6 @@
package dna.metrics.streaM_k;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.IMetric;
import dna.metrics.Metric;
import dna.series.data.Value;
@@ -65,7 +65,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return !g.isDirected();
}
diff --git a/src/dna/metrics/streaM_k/StreaM_k.java b/src/dna/metrics/streaM_k/StreaM_k.java
index 9dad1b2a..c6682c46 100644
--- a/src/dna/metrics/streaM_k/StreaM_k.java
+++ b/src/dna/metrics/streaM_k/StreaM_k.java
@@ -3,8 +3,8 @@
import java.io.IOException;
import java.util.HashSet;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.metrics.IMetric;
@@ -102,7 +102,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return !g.isDirected();
}
@@ -156,7 +156,7 @@ public boolean init() {
this.motifs = new BinnedIntDistr("motifs", 1,
new long[this.umm.getMotifsCount() + 1], 0);
- Graph original = this.g;
+ IGraph original = this.g;
this.g = this.g.getGraphDatastructures().newGraphInstance("temp", 0,
this.g.getNodeCount(), this.g.getEdgeCount());
diff --git a/src/dna/metrics/streaM_k/StreaM_k2.java b/src/dna/metrics/streaM_k/StreaM_k2.java
index 94e4067a..0b3bf5db 100644
--- a/src/dna/metrics/streaM_k/StreaM_k2.java
+++ b/src/dna/metrics/streaM_k/StreaM_k2.java
@@ -3,8 +3,8 @@
import java.io.IOException;
import java.util.HashSet;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.metrics.algorithms.IAfterER;
@@ -90,7 +90,7 @@ public boolean init() {
// return true;
// }
- Graph original = this.g;
+ IGraph original = this.g;
this.g = this.g.getGraphDatastructures().newGraphInstance("temp", 0,
this.g.getNodeCount(), this.g.getEdgeCount());
diff --git a/src/dna/metrics/streaM_k/grouping/Grouping.java b/src/dna/metrics/streaM_k/grouping/Grouping.java
index adde77e0..5c12f4f8 100644
--- a/src/dna/metrics/streaM_k/grouping/Grouping.java
+++ b/src/dna/metrics/streaM_k/grouping/Grouping.java
@@ -3,19 +3,19 @@
import java.util.Arrays;
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
public abstract class Grouping {
- public int[] getKeys(Graph g, Node n1, Node n2, String group) {
+ public int[] getKeys(IGraph g, Node n1, Node n2, String group) {
int key0 = Integer.parseInt('0' + this.getKey(g, n1, n2, group), 2);
int key1 = Integer.parseInt('1' + this.getKey(g, n1, n2, group), 2);
return new int[] { key0, key1 };
}
- protected String getKey(Graph g, Node n1, Node n2, String group) {
+ protected String getKey(IGraph g, Node n1, Node n2, String group) {
String[] temp = group.split(";");
Node[] nodes = new Node[temp.length + 2];
nodes[0] = n1;
@@ -66,7 +66,7 @@ protected static void add(HashSet set, Node l, Node r,
set.add(buff.toString());
}
- public HashSet getGroups(Graph g, int nodes, Edge e) {
+ public HashSet getGroups(IGraph g, int nodes, Edge e) {
if (nodes == 3) {
return getGroups3(e);
} else if (nodes == 4) {
diff --git a/src/dna/metrics/streaM_k/grouping/GroupingV3.java b/src/dna/metrics/streaM_k/grouping/GroupingV3.java
index f60e0c80..3c313919 100644
--- a/src/dna/metrics/streaM_k/grouping/GroupingV3.java
+++ b/src/dna/metrics/streaM_k/grouping/GroupingV3.java
@@ -2,15 +2,15 @@
import java.util.HashSet;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
public class GroupingV3 extends GroupingV1 {
@Override
- protected String getKey(Graph g, Node a, Node b, String group) {
+ protected String getKey(IGraph g, Node a, Node b, String group) {
String[] temp = group.split(";");
Node c = g.getNode(Integer.parseInt(temp[0]));
diff --git a/src/dna/metrics/streaM_k/grouping/GroupingV4.java b/src/dna/metrics/streaM_k/grouping/GroupingV4.java
index 2ebea4bd..de7e4ac4 100644
--- a/src/dna/metrics/streaM_k/grouping/GroupingV4.java
+++ b/src/dna/metrics/streaM_k/grouping/GroupingV4.java
@@ -1,12 +1,12 @@
package dna.metrics.streaM_k.grouping;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
public class GroupingV4 extends GroupingV3 {
@Override
- public String getKey(Graph g, Node a, Node b, String group) {
+ public String getKey(IGraph g, Node a, Node b, String group) {
String[] temp = group.split(";");
Node c = g.getNode(Integer.parseInt(temp[0]));
@@ -19,7 +19,7 @@ public String getKey(Graph g, Node a, Node b, String group) {
}
@Override
- public int[] getKeys(Graph g, Node a, Node b, String group) {
+ public int[] getKeys(IGraph g, Node a, Node b, String group) {
int key0 = 0;
int key1 = 2;
diff --git a/src/dna/metrics/streaM_k/grouping/GroupingV5.java b/src/dna/metrics/streaM_k/grouping/GroupingV5.java
index c96b3e16..a0e0e69f 100644
--- a/src/dna/metrics/streaM_k/grouping/GroupingV5.java
+++ b/src/dna/metrics/streaM_k/grouping/GroupingV5.java
@@ -1,12 +1,12 @@
package dna.metrics.streaM_k.grouping;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
public class GroupingV5 extends GroupingV3 {
@Override
- public int[] getKeys(Graph g, Node a, Node b, String group) {
+ public int[] getKeys(IGraph g, Node a, Node b, String group) {
int key0 = 0;
String[] temp = group.split(";");
diff --git a/src/dna/metrics/streaM_k/groupingWithGroups/Grouping2.java b/src/dna/metrics/streaM_k/groupingWithGroups/Grouping2.java
index bf273fcd..9d9691fe 100644
--- a/src/dna/metrics/streaM_k/groupingWithGroups/Grouping2.java
+++ b/src/dna/metrics/streaM_k/groupingWithGroups/Grouping2.java
@@ -1,11 +1,8 @@
package dna.metrics.streaM_k.groupingWithGroups;
-import java.util.Arrays;
import java.util.HashSet;
-import dna.graph.Graph;
import dna.graph.edges.Edge;
-import dna.graph.nodes.Node;
public abstract class Grouping2 {
diff --git a/src/dna/metrics/weights/EdgeWeights.java b/src/dna/metrics/weights/EdgeWeights.java
index 4e9a4448..5615ff87 100644
--- a/src/dna/metrics/weights/EdgeWeights.java
+++ b/src/dna/metrics/weights/EdgeWeights.java
@@ -1,7 +1,7 @@
package dna.metrics.weights;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.IEdge;
import dna.graph.weights.IWeightedEdge;
import dna.graph.weights.doubleW.DoubleWeight;
@@ -31,7 +31,7 @@ public boolean isComparableTo(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isEdgeType(IWeightedEdge.class)
&& g.getGraphDatastructures().isEdgeWeightType(IntWeight.class,
DoubleWeight.class);
diff --git a/src/dna/metrics/weights/NodeWeights.java b/src/dna/metrics/weights/NodeWeights.java
index b6b9c7df..c42766ac 100644
--- a/src/dna/metrics/weights/NodeWeights.java
+++ b/src/dna/metrics/weights/NodeWeights.java
@@ -1,7 +1,7 @@
package dna.metrics.weights;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.INode;
import dna.graph.weights.IWeightedNode;
import dna.graph.weights.doubleW.DoubleWeight;
@@ -31,7 +31,7 @@ public boolean isComparableTo(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(IWeightedNode.class)
&& g.getGraphDatastructures().isNodeWeightType(IntWeight.class,
DoubleWeight.class);
diff --git a/src/dna/metrics/weights/RootMeanSquareDeviation.java b/src/dna/metrics/weights/RootMeanSquareDeviation.java
index 8eb1dca0..1963a322 100644
--- a/src/dna/metrics/weights/RootMeanSquareDeviation.java
+++ b/src/dna/metrics/weights/RootMeanSquareDeviation.java
@@ -1,6 +1,6 @@
package dna.metrics.weights;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.weights.IWeightedNode;
import dna.graph.weights.doubleW.Double2dWeight;
import dna.graph.weights.doubleW.Double3dWeight;
@@ -85,7 +85,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(IWeightedNode.class)
&& g.getGraphDatastructures().isNodeWeightType(
DoubleWeight.class, Double2dWeight.class,
diff --git a/src/dna/metrics/weights/RootMeanSquareFluctuation.java b/src/dna/metrics/weights/RootMeanSquareFluctuation.java
index 847dcb0e..adc8e387 100644
--- a/src/dna/metrics/weights/RootMeanSquareFluctuation.java
+++ b/src/dna/metrics/weights/RootMeanSquareFluctuation.java
@@ -3,7 +3,7 @@
import java.util.HashMap;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.graph.weights.IWeightedNode;
import dna.graph.weights.Weight;
@@ -100,7 +100,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return g.getGraphDatastructures().isNodeType(IWeightedNode.class)
&& g.getGraphDatastructures().isNodeWeightType(
DoubleWeight.class, Double2dWeight.class,
diff --git a/src/dna/metrics/workload/Operation.java b/src/dna/metrics/workload/Operation.java
index c6298c55..156cb857 100644
--- a/src/dna/metrics/workload/Operation.java
+++ b/src/dna/metrics/workload/Operation.java
@@ -1,6 +1,6 @@
package dna.metrics.workload;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.util.Log;
import dna.util.parameters.IntParameter;
import dna.util.parameters.Parameter;
@@ -52,7 +52,7 @@ public Operation(String name, ListType listType, int times,
* @param g
* graph
*/
- public void createWorkload(Graph g) {
+ public void createWorkload(IGraph g) {
switch (this.list) {
case E:
for (int i = 0; i < this.times; i++) {
@@ -104,7 +104,7 @@ public void createWorkload(Graph g) {
* @param g
* graph
*/
- public void init(Graph g) {
+ public void init(IGraph g) {
// nothing is done by default, must be overwritten to do something
}
@@ -114,7 +114,7 @@ public void init(Graph g) {
* @param g
* graph
*/
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
Log.error("the operation " + this.getName()
+ " does not implement workload for E");
}
@@ -125,7 +125,7 @@ protected void createWorkloadE(Graph g) {
* @param g
* graph
*/
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
Log.error("the operation " + this.getName()
+ " does not implement workload for V");
}
@@ -138,7 +138,7 @@ protected void createWorkloadV(Graph g) {
* @param g
* graph
*/
- protected void createWorkloadIn(Graph g) {
+ protected void createWorkloadIn(IGraph g) {
Log.error("the operation " + this.getName()
+ " does not implement workload for IN");
}
@@ -150,7 +150,7 @@ protected void createWorkloadIn(Graph g) {
*
* @param g
*/
- protected void createWorkloadOut(Graph g) {
+ protected void createWorkloadOut(IGraph g) {
Log.error("the operation " + this.getName()
+ " does not implement workload for OUT");
}
@@ -163,7 +163,7 @@ protected void createWorkloadOut(Graph g) {
*
* @param g
*/
- protected void createWorkloadNeighbors(Graph g) {
+ protected void createWorkloadNeighbors(IGraph g) {
Log.error("the operation " + this.getName()
+ " does not implement workload for NEIGHBORS");
}
@@ -174,7 +174,7 @@ protected void createWorkloadNeighbors(Graph g) {
*
* @param g
*/
- protected void createWorkloadAdj(Graph g) {
+ protected void createWorkloadAdj(IGraph g) {
Log.error("the operation " + this.getName()
+ " does not implement workload for ADJ");
}
diff --git a/src/dna/metrics/workload/OperationWithRandomSample.java b/src/dna/metrics/workload/OperationWithRandomSample.java
index d9d9adbd..e100f575 100644
--- a/src/dna/metrics/workload/OperationWithRandomSample.java
+++ b/src/dna/metrics/workload/OperationWithRandomSample.java
@@ -1,6 +1,6 @@
package dna.metrics.workload;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.util.parameters.IntParameter;
@@ -69,7 +69,7 @@ public OperationWithRandomSample(String name, ListType list, int times,
}
@Override
- public void init(Graph g) {
+ public void init(IGraph g) {
for (int i = 0; i < this.nodes.length; i++) {
this.nodes[i] = g.getRandomNode();
}
diff --git a/src/dna/metrics/workload/Workload.java b/src/dna/metrics/workload/Workload.java
index e96cf8ac..41745c8f 100644
--- a/src/dna/metrics/workload/Workload.java
+++ b/src/dna/metrics/workload/Workload.java
@@ -1,6 +1,6 @@
package dna.metrics.workload;
-import dna.graph.Graph;
+import dna.graph.IGraph;
/**
*
@@ -28,7 +28,7 @@ public Workload(int rounds, Operation... operations) {
* @param g
* graph
*/
- public void createWorkload(Graph g) {
+ public void createWorkload(IGraph g) {
for (Operation o : this.operations) {
o.createWorkload(g);
}
@@ -41,7 +41,7 @@ public void createWorkload(Graph g) {
* @param g
* g
*/
- public void init(Graph g) {
+ public void init(IGraph g) {
for (Operation o : this.operations) {
o.init(g);
}
diff --git a/src/dna/metrics/workload/WorkloadMetric.java b/src/dna/metrics/workload/WorkloadMetric.java
index 48ba57f5..d13d33c6 100644
--- a/src/dna/metrics/workload/WorkloadMetric.java
+++ b/src/dna/metrics/workload/WorkloadMetric.java
@@ -1,6 +1,6 @@
package dna.metrics.workload;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.IMetric;
import dna.metrics.Metric;
import dna.metrics.algorithms.IRecomputation;
@@ -110,7 +110,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return true;
}
diff --git a/src/dna/metrics/workload/operations/AddSuccess.java b/src/dna/metrics/workload/operations/AddSuccess.java
index fbb34483..ff5e4a18 100644
--- a/src/dna/metrics/workload/operations/AddSuccess.java
+++ b/src/dna/metrics/workload/operations/AddSuccess.java
@@ -4,7 +4,7 @@
import java.util.PriorityQueue;
import java.util.Queue;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.metrics.workload.Operation;
@@ -33,7 +33,7 @@ public AddSuccess(ListType list, int times) {
}
@Override
- public void init(Graph g) {
+ public void init(IGraph g) {
if (ListType.E.equals(this.list)) {
HashSet newEdges = new HashSet(this.times);
while (newEdges.size() < this.times) {
@@ -52,12 +52,12 @@ public void init(Graph g) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
g.addEdge(this.newEdges.poll());
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
Node node = g.getGraphDatastructures().newNodeInstance(
g.getMaxNodeIndex() + 1);
g.addNode(node);
diff --git a/src/dna/metrics/workload/operations/BFS.java b/src/dna/metrics/workload/operations/BFS.java
index 87e71c40..b54cbaca 100644
--- a/src/dna/metrics/workload/operations/BFS.java
+++ b/src/dna/metrics/workload/operations/BFS.java
@@ -3,7 +3,7 @@
import java.util.HashSet;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.UndirectedEdge;
@@ -35,12 +35,12 @@ public BFS(int times, int samples) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
Log.error("BFSWorkload is not implemented for list type E");
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
HashSet seen = new HashSet();
Node start = this.getSampleNode();
seen.add(start);
diff --git a/src/dna/metrics/workload/operations/ContainsFailure.java b/src/dna/metrics/workload/operations/ContainsFailure.java
index 5a2bb88c..20400055 100644
--- a/src/dna/metrics/workload/operations/ContainsFailure.java
+++ b/src/dna/metrics/workload/operations/ContainsFailure.java
@@ -1,6 +1,6 @@
package dna.metrics.workload.operations;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.DirectedNode;
@@ -35,7 +35,7 @@ public ContainsFailure(ListType list, int times) {
}
@Override
- public void init(Graph g) {
+ public void init(IGraph g) {
this.node1 = g.getGraphDatastructures().newNodeInstance(
Integer.MAX_VALUE);
this.node2 = g.getGraphDatastructures().newNodeInstance(
@@ -45,38 +45,38 @@ public void init(Graph g) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
g.containsEdge(this.edge);
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
g.containsNode(this.node1);
}
@Override
- protected void createWorkloadIn(Graph g) {
+ protected void createWorkloadIn(IGraph g) {
for (IElement n_ : g.getNodes()) {
((DirectedNode) n_).hasEdge(this.edge);
}
}
@Override
- protected void createWorkloadOut(Graph g) {
+ protected void createWorkloadOut(IGraph g) {
for (IElement n_ : g.getNodes()) {
((DirectedNode) n_).hasEdge(this.edge);
}
}
@Override
- protected void createWorkloadNeighbors(Graph g) {
+ protected void createWorkloadNeighbors(IGraph g) {
for (IElement n_ : g.getNodes()) {
((DirectedNode) n_).hasNeighbor((DirectedNode) this.node1);
}
}
@Override
- protected void createWorkloadAdj(Graph g) {
+ protected void createWorkloadAdj(IGraph g) {
for (IElement n_ : g.getNodes()) {
((Node) n_).hasEdge(this.edge);
}
diff --git a/src/dna/metrics/workload/operations/ContainsSuccess.java b/src/dna/metrics/workload/operations/ContainsSuccess.java
index 2b904e9c..e1ed5cf0 100644
--- a/src/dna/metrics/workload/operations/ContainsSuccess.java
+++ b/src/dna/metrics/workload/operations/ContainsSuccess.java
@@ -1,6 +1,6 @@
package dna.metrics.workload.operations;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.workload.OperationWithRandomSample;
/**
@@ -27,12 +27,12 @@ public ContainsSuccess(ListType list, int times, int samples) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
g.containsEdge(this.getSampleEdge());
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
g.containsNode(this.getSampleNode());
}
diff --git a/src/dna/metrics/workload/operations/DFS.java b/src/dna/metrics/workload/operations/DFS.java
index 194a838f..0bc61290 100644
--- a/src/dna/metrics/workload/operations/DFS.java
+++ b/src/dna/metrics/workload/operations/DFS.java
@@ -3,7 +3,7 @@
import java.util.HashSet;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.UndirectedEdge;
@@ -35,12 +35,12 @@ public DFS(int times, int samples) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
Log.error("DFSWorkload is not implemented for list type E");
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
HashSet seen = new HashSet();
Node start = this.getSampleNode();
seen.add(start);
diff --git a/src/dna/metrics/workload/operations/GetFailure.java b/src/dna/metrics/workload/operations/GetFailure.java
index 632456c6..bdc211c7 100644
--- a/src/dna/metrics/workload/operations/GetFailure.java
+++ b/src/dna/metrics/workload/operations/GetFailure.java
@@ -1,6 +1,6 @@
package dna.metrics.workload.operations;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.metrics.workload.Operation;
@@ -32,7 +32,7 @@ public GetFailure(ListType list, int times) {
}
@Override
- public void init(Graph g) {
+ public void init(IGraph g) {
this.node1 = g.getGraphDatastructures().newNodeInstance(
Integer.MAX_VALUE);
this.node2 = g.getGraphDatastructures().newNodeInstance(
@@ -42,12 +42,12 @@ public void init(Graph g) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
g.getEdge(this.node1, this.node2);
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
g.getNode(this.node1.getIndex());
}
diff --git a/src/dna/metrics/workload/operations/GetSuccess.java b/src/dna/metrics/workload/operations/GetSuccess.java
index 26b171cf..41170ef8 100644
--- a/src/dna/metrics/workload/operations/GetSuccess.java
+++ b/src/dna/metrics/workload/operations/GetSuccess.java
@@ -1,6 +1,6 @@
package dna.metrics.workload.operations;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.metrics.workload.OperationWithRandomSample;
@@ -27,13 +27,13 @@ public GetSuccess(ListType list, int times, int samples) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
Edge e = this.getSampleEdge();
g.getEdge(e.getN1(), e.getN2());
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
g.getNode(this.getSampleNode().getIndex());
}
diff --git a/src/dna/metrics/workload/operations/Iterate.java b/src/dna/metrics/workload/operations/Iterate.java
index b2bbfa6c..1f28d9a0 100644
--- a/src/dna/metrics/workload/operations/Iterate.java
+++ b/src/dna/metrics/workload/operations/Iterate.java
@@ -1,6 +1,6 @@
package dna.metrics.workload.operations;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.Edge;
@@ -29,7 +29,7 @@ public Iterate(ListType list, int times) {
@SuppressWarnings("unused")
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
Edge edge = null;
for (IElement e : g.getEdges()) {
edge = (Edge) e;
@@ -38,7 +38,7 @@ protected void createWorkloadE(Graph g) {
@SuppressWarnings("unused")
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
Node node = null;
for (IElement n : g.getNodes()) {
node = (Node) n;
@@ -47,7 +47,7 @@ protected void createWorkloadV(Graph g) {
@SuppressWarnings("unused")
@Override
- protected void createWorkloadIn(Graph g) {
+ protected void createWorkloadIn(IGraph g) {
DirectedEdge edge = null;
for (IElement n_ : g.getNodes()) {
for (IElement e_ : ((DirectedNode) n_).getIncomingEdges()) {
@@ -58,7 +58,7 @@ protected void createWorkloadIn(Graph g) {
@SuppressWarnings("unused")
@Override
- protected void createWorkloadOut(Graph g) {
+ protected void createWorkloadOut(IGraph g) {
DirectedEdge edge = null;
for (IElement n_ : g.getNodes()) {
for (IElement e_ : ((DirectedNode) n_).getOutgoingEdges()) {
@@ -69,7 +69,7 @@ protected void createWorkloadOut(Graph g) {
@SuppressWarnings("unused")
@Override
- protected void createWorkloadNeighbors(Graph g) {
+ protected void createWorkloadNeighbors(IGraph g) {
DirectedNode node = null;
for (IElement n_ : g.getNodes()) {
for (IElement nn_ : ((DirectedNode) n_).getNeighbors()) {
@@ -80,7 +80,7 @@ protected void createWorkloadNeighbors(Graph g) {
@SuppressWarnings("unused")
@Override
- protected void createWorkloadAdj(Graph g) {
+ protected void createWorkloadAdj(IGraph g) {
Edge edge = null;
for (IElement n_ : g.getNodes()) {
for (IElement e_ : ((Node) n_).getEdges()) {
diff --git a/src/dna/metrics/workload/operations/MetricComputation.java b/src/dna/metrics/workload/operations/MetricComputation.java
index 123dbb05..61333140 100644
--- a/src/dna/metrics/workload/operations/MetricComputation.java
+++ b/src/dna/metrics/workload/operations/MetricComputation.java
@@ -1,6 +1,6 @@
package dna.metrics.workload.operations;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.algorithms.IRecomputation;
import dna.metrics.workload.Operation;
import dna.util.parameters.StringParameter;
@@ -16,7 +16,7 @@ public MetricComputation(int times, IRecomputation metric) {
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
this.metric.setGraph(g);
this.metric.reset();
this.metric.recompute();
diff --git a/src/dna/metrics/workload/operations/RandomElement.java b/src/dna/metrics/workload/operations/RandomElement.java
index aa14a815..c8ce7b6f 100644
--- a/src/dna/metrics/workload/operations/RandomElement.java
+++ b/src/dna/metrics/workload/operations/RandomElement.java
@@ -1,6 +1,6 @@
package dna.metrics.workload.operations;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.workload.Operation;
/**
@@ -23,12 +23,12 @@ public RandomElement(ListType list, int times) {
}
@Override
- protected void createWorkloadE(Graph g) {
+ protected void createWorkloadE(IGraph g) {
g.getRandomEdge();
}
@Override
- protected void createWorkloadV(Graph g) {
+ protected void createWorkloadV(IGraph g) {
g.getRandomNode();
}
diff --git a/src/dna/parallel/collation/Collation.java b/src/dna/parallel/collation/Collation.java
index bc25ae97..45f2207c 100644
--- a/src/dna/parallel/collation/Collation.java
+++ b/src/dna/parallel/collation/Collation.java
@@ -3,7 +3,7 @@
import java.io.File;
import java.util.ArrayList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.metrics.IMetric;
import dna.metrics.Metric;
import dna.metrics.algorithms.IRecomputation;
@@ -310,7 +310,7 @@ public boolean equals(IMetric m) {
}
@Override
- public boolean isApplicable(Graph g) {
+ public boolean isApplicable(IGraph g) {
return this.m.isApplicable(g);
}
diff --git a/src/dna/parallel/partition/AllPartitions.java b/src/dna/parallel/partition/AllPartitions.java
index 74ede858..13d3cb4b 100644
--- a/src/dna/parallel/partition/AllPartitions.java
+++ b/src/dna/parallel/partition/AllPartitions.java
@@ -2,7 +2,7 @@
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.parallel.auxData.AuxData;
import dna.parallel.partition.Partition.PartitionType;
@@ -11,13 +11,13 @@
public class AllPartitions> extends
ParameterList {
public PartitionType partitionType;
- public Graph g;
+ public IGraph g;
public T[] partitions;
public D auxData;
// public HashMap mapping;
- public AllPartitions(String name, PartitionType partitionType, Graph g,
+ public AllPartitions(String name, PartitionType partitionType, IGraph g,
T[] partitions, D auxData, HashMap mapping) {
super(name);
this.partitionType = partitionType;
diff --git a/src/dna/parallel/partition/CompletePartition.java b/src/dna/parallel/partition/CompletePartition.java
index 84c3ba60..dce54b44 100644
--- a/src/dna/parallel/partition/CompletePartition.java
+++ b/src/dna/parallel/partition/CompletePartition.java
@@ -5,8 +5,8 @@
import java.util.List;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.parallel.auxData.CompleteAuxData;
@@ -17,14 +17,14 @@
public class CompletePartition extends Partition {
- public CompletePartition(Graph g) {
+ public CompletePartition(IGraph g) {
super(g);
// TODO Auto-generated constructor stub
}
public static AllPartitions partition(
- String name, Graph g, List[] nodess) {
- Graph[] graphs = getInitialGraphs(g, nodess);
+ String name, IGraph g, List[] nodess) {
+ IGraph[] graphs = getInitialGraphs(g, nodess);
for (int i = 0; i < graphs.length; i++) {
for (int j = 0; j < graphs.length; j++) {
if (j == i) {
diff --git a/src/dna/parallel/partition/NodeCutPartition.java b/src/dna/parallel/partition/NodeCutPartition.java
index 016e00df..6cf11498 100644
--- a/src/dna/parallel/partition/NodeCutPartition.java
+++ b/src/dna/parallel/partition/NodeCutPartition.java
@@ -3,20 +3,20 @@
import java.util.HashMap;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.parallel.auxData.NodeCutAuxData;
public class NodeCutPartition extends Partition {
- public NodeCutPartition(Graph g) {
+ public NodeCutPartition(IGraph g) {
super(g);
// TODO Auto-generated constructor stub
}
public static AllPartitions partition(
- String name, Graph g, List[] nodess) {
- Graph[] graphs = getInitialGraphs(g, nodess);
+ String name, IGraph g, List[] nodess) {
+ IGraph[] graphs = getInitialGraphs(g, nodess);
NodeCutPartition[] partitions = new NodeCutPartition[nodess.length];
HashMap mapping = new HashMap();
for (int i = 0; i < graphs.length; i++) {
diff --git a/src/dna/parallel/partition/OverlappingPartition.java b/src/dna/parallel/partition/OverlappingPartition.java
index 9c498339..464ad196 100644
--- a/src/dna/parallel/partition/OverlappingPartition.java
+++ b/src/dna/parallel/partition/OverlappingPartition.java
@@ -6,8 +6,8 @@
import java.util.List;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.edges.IEdge;
import dna.graph.nodes.Node;
@@ -23,7 +23,7 @@
public class OverlappingPartition extends Partition {
- public OverlappingPartition(Graph g) {
+ public OverlappingPartition(IGraph g) {
super(g);
// TODO Auto-generated constructor stub
}
@@ -33,8 +33,8 @@ public OverlappingPartition(Graph g) {
*/
public static AllPartitions partition(
- String name, Graph g, List[] nodess) {
- Graph[] graphs = getInitialGraphs(g, nodess);
+ String name, IGraph g, List[] nodess) {
+ IGraph[] graphs = getInitialGraphs(g, nodess);
OverlappingPartition[] partitions = new OverlappingPartition[nodess.length];
HashMap mapping = new HashMap();
for (int i = 0; i < graphs.length; i++) {
@@ -608,7 +608,7 @@ protected static ArrayList getNeighboringPartitions(
* update which is currently processed and results in this
* addition (log only)
*/
- public static void add(Graph g, Batch[] batches, int index, Update u,
+ public static void add(IGraph g, Batch[] batches, int index, Update u,
String name, Update current) {
if (u instanceof EdgeRemoval) {
EdgeAddition addition = batches[index]
diff --git a/src/dna/parallel/partition/Partition.java b/src/dna/parallel/partition/Partition.java
index 462025f0..9aaaf0f8 100644
--- a/src/dna/parallel/partition/Partition.java
+++ b/src/dna/parallel/partition/Partition.java
@@ -2,7 +2,7 @@
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.batch.Batch;
@@ -14,15 +14,15 @@ public static enum PartitionType {
NodeCut, Separated, Overlapping, Complete
}
- public Graph g;
+ public IGraph g;
- public Partition(Graph g) {
+ public Partition(IGraph g) {
this.g = g;
}
- protected static Graph getInitialGraph(Graph g, List nodes,
+ protected static IGraph getInitialGraph(IGraph g, List nodes,
String name) {
- Graph g_ = g.getGraphDatastructures().newGraphInstance(name,
+ IGraph g_ = g.getGraphDatastructures().newGraphInstance(name,
g.getTimestamp(), nodes.size(), 0);
for (Node n : nodes) {
// TODO not handling weighted nodes yet!
@@ -32,8 +32,8 @@ protected static Graph getInitialGraph(Graph g, List nodes,
return g_;
}
- protected static Graph[] getInitialGraphs(Graph g, List[] nodess) {
- Graph[] graphs = new Graph[nodess.length];
+ protected static IGraph[] getInitialGraphs(IGraph g, List[] nodess) {
+ IGraph[] graphs = new IGraph[nodess.length];
for (int i = 0; i < graphs.length; i++) {
graphs[i] = getInitialGraph(g, nodess[i], "partition" + i);
}
diff --git a/src/dna/parallel/partition/SeparatedPartition.java b/src/dna/parallel/partition/SeparatedPartition.java
index 39a80f13..29566220 100644
--- a/src/dna/parallel/partition/SeparatedPartition.java
+++ b/src/dna/parallel/partition/SeparatedPartition.java
@@ -5,8 +5,8 @@
import java.util.List;
import java.util.Set;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.parallel.auxData.SeparatedAuxData;
@@ -20,14 +20,14 @@
public class SeparatedPartition extends Partition {
- public SeparatedPartition(Graph g) {
+ public SeparatedPartition(IGraph g) {
super(g);
// TODO Auto-generated constructor stub
}
public static AllPartitions partition(
- String name, Graph g, List[] nodess) {
- Graph[] graphs = getInitialGraphs(g, nodess);
+ String name, IGraph g, List[] nodess) {
+ IGraph[] graphs = getInitialGraphs(g, nodess);
SeparatedPartition[] partitions = new SeparatedPartition[nodess.length];
HashMap mapping = new HashMap();
for (int i = 0; i < graphs.length; i++) {
diff --git a/src/dna/parallel/partitioning/BFSPartitioning.java b/src/dna/parallel/partitioning/BFSPartitioning.java
index b5464359..08c0c287 100644
--- a/src/dna/parallel/partitioning/BFSPartitioning.java
+++ b/src/dna/parallel/partitioning/BFSPartitioning.java
@@ -6,8 +6,8 @@
import java.util.List;
import java.util.Queue;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -18,7 +18,7 @@ public BFSPartitioning() {
}
@Override
- protected List[] partition(Graph g, int partitionCount) {
+ protected List[] partition(IGraph g, int partitionCount) {
HashSet visited = new HashSet(g.getNodeCount());
List sorted = new ArrayList(g.getNodeCount());
diff --git a/src/dna/parallel/partitioning/DFSPartitioning.java b/src/dna/parallel/partitioning/DFSPartitioning.java
index a025e1b2..5d7282d8 100644
--- a/src/dna/parallel/partitioning/DFSPartitioning.java
+++ b/src/dna/parallel/partitioning/DFSPartitioning.java
@@ -5,8 +5,8 @@
import java.util.LinkedList;
import java.util.List;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -17,7 +17,7 @@ public DFSPartitioning() {
}
@Override
- protected List[] partition(Graph g, int partitionCount) {
+ protected List[] partition(IGraph g, int partitionCount) {
List sorted = new ArrayList(g.getNodeCount());
HashSet seen = new HashSet(g.getNodeCount());
diff --git a/src/dna/parallel/partitioning/EqualSizePartitioning.java b/src/dna/parallel/partitioning/EqualSizePartitioning.java
index 7c31c3be..0d51b6f4 100644
--- a/src/dna/parallel/partitioning/EqualSizePartitioning.java
+++ b/src/dna/parallel/partitioning/EqualSizePartitioning.java
@@ -3,8 +3,8 @@
import java.util.ArrayList;
import java.util.List;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
public class EqualSizePartitioning extends Partitioning {
@@ -14,7 +14,7 @@ public EqualSizePartitioning() {
}
@Override
- protected List[] partition(Graph g, int partitionCount) {
+ protected List[] partition(IGraph g, int partitionCount) {
List sorted = new ArrayList(g.getNodeCount());
for (IElement n : g.getNodes()) {
sorted.add((Node) n);
diff --git a/src/dna/parallel/partitioning/LPAPartitioning.java b/src/dna/parallel/partitioning/LPAPartitioning.java
index b31370a1..3763e062 100644
--- a/src/dna/parallel/partitioning/LPAPartitioning.java
+++ b/src/dna/parallel/partitioning/LPAPartitioning.java
@@ -2,7 +2,7 @@
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
public class LPAPartitioning extends Partitioning {
@@ -12,7 +12,7 @@ public LPAPartitioning() {
}
@Override
- protected List[] partition(Graph g, int partitionCount) {
+ protected List[] partition(IGraph g, int partitionCount) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/dna/parallel/partitioning/Partitioning.java b/src/dna/parallel/partitioning/Partitioning.java
index c9e8d5f2..33c748ec 100644
--- a/src/dna/parallel/partitioning/Partitioning.java
+++ b/src/dna/parallel/partitioning/Partitioning.java
@@ -3,14 +3,14 @@
import java.util.ArrayList;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.parallel.partition.AllPartitions;
import dna.parallel.partition.CompletePartition;
import dna.parallel.partition.NodeCutPartition;
-import dna.parallel.partition.SeparatedPartition;
import dna.parallel.partition.OverlappingPartition;
import dna.parallel.partition.Partition.PartitionType;
+import dna.parallel.partition.SeparatedPartition;
import dna.util.parameters.Parameter;
import dna.util.parameters.ParameterList;
@@ -20,10 +20,10 @@ public Partitioning(String name, Parameter... parameters) {
super(name, parameters);
}
- protected abstract List[] partition(Graph g, int partitionCount);
+ protected abstract List[] partition(IGraph g, int partitionCount);
@SuppressWarnings("rawtypes")
- public AllPartitions getPartition(PartitionType partitionType, Graph g,
+ public AllPartitions getPartition(PartitionType partitionType, IGraph g,
int partitionCount) {
switch (partitionType) {
case NodeCut:
@@ -45,7 +45,7 @@ public AllPartitions getPartition(PartitionType partitionType, Graph g,
}
@SuppressWarnings("unchecked")
- protected List[] getInitialList(Graph g, int partitionCount) {
+ protected List[] getInitialList(IGraph g, int partitionCount) {
List[] p = (List[]) new ArrayList[partitionCount];
for (int i = 0; i < p.length; i++) {
p[i] = new ArrayList(1 + g.getNodeCount() / partitionCount);
@@ -53,7 +53,7 @@ protected List[] getInitialList(Graph g, int partitionCount) {
return p;
}
- protected List[] split(Graph g, List sorted, int partitionCount) {
+ protected List[] split(IGraph g, List sorted, int partitionCount) {
int partitionSize = (int) Math.ceil(1.0 * g.getNodeCount()
/ partitionCount);
List[] partitioning = getInitialList(g, partitionCount);
diff --git a/src/dna/parallel/partitioning/RandomPartitioning.java b/src/dna/parallel/partitioning/RandomPartitioning.java
index bcc999ea..c82080e7 100644
--- a/src/dna/parallel/partitioning/RandomPartitioning.java
+++ b/src/dna/parallel/partitioning/RandomPartitioning.java
@@ -2,8 +2,8 @@
import java.util.List;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.util.Rand;
@@ -14,7 +14,7 @@ public RandomPartitioning() {
}
@Override
- protected List[] partition(Graph g, int partitionCount) {
+ protected List[] partition(IGraph g, int partitionCount) {
List[] nodess = this.getInitialList(g, partitionCount);
for (IElement n : g.getNodes()) {
nodess[Rand.rand.nextInt(partitionCount)].add((Node) n);
diff --git a/src/dna/parallel/util/ReadableDirConsecutiveWaitingBatchGenerator.java b/src/dna/parallel/util/ReadableDirConsecutiveWaitingBatchGenerator.java
index 0d915589..94db097f 100644
--- a/src/dna/parallel/util/ReadableDirConsecutiveWaitingBatchGenerator.java
+++ b/src/dna/parallel/util/ReadableDirConsecutiveWaitingBatchGenerator.java
@@ -2,7 +2,7 @@
import java.io.File;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.io.BatchReader;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -23,7 +23,7 @@ public ReadableDirConsecutiveWaitingBatchGenerator(String name, String dir,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
this.sleeper.reset();
String filename = (g.getTimestamp() + 1) + this.suffix;
while (!this.sleeper.isTimedOut()) {
@@ -42,7 +42,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return true;
}
}
diff --git a/src/dna/parallel/util/ReadableFileWaitingGraph.java b/src/dna/parallel/util/ReadableFileWaitingGraph.java
index b7cf2353..7ffff3ed 100644
--- a/src/dna/parallel/util/ReadableFileWaitingGraph.java
+++ b/src/dna/parallel/util/ReadableFileWaitingGraph.java
@@ -3,7 +3,7 @@
import java.io.File;
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.generators.GraphGenerator;
import dna.io.GraphReader;
@@ -60,7 +60,7 @@ public ReadableFileWaitingGraph(String dir, String filename,
}
@Override
- public Graph generate() {
+ public IGraph generate() {
this.sleeper.reset();
while (!this.sleeper.isTimedOut()) {
if (!(new File(this.dir + this.filename)).exists()) {
diff --git a/src/dna/series/Series.java b/src/dna/series/Series.java
index 7abe1392..00f08586 100644
--- a/src/dna/series/Series.java
+++ b/src/dna/series/Series.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.generators.GraphGenerator;
import dna.metrics.IMetric;
import dna.metrics.MetricNotApplicableException;
@@ -100,7 +100,7 @@ public SeriesData generateRuns(int from, int to, int batches,
private String dir;
- private Graph graph;
+ private IGraph graph;
private String name;
@@ -120,11 +120,11 @@ public String getDir() {
return this.dir;
}
- public Graph getGraph() {
+ public IGraph getGraph() {
return this.graph;
}
- public void setGraph(Graph graph) {
+ public void setGraph(IGraph graph) {
this.graph = graph;
}
diff --git a/src/dna/updates/batch/Batch.java b/src/dna/updates/batch/Batch.java
index c2a5337b..e3b90ca6 100644
--- a/src/dna/updates/batch/Batch.java
+++ b/src/dna/updates/batch/Batch.java
@@ -5,7 +5,7 @@
import com.google.common.collect.Iterables;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.edges.IEdge;
@@ -70,7 +70,7 @@ public Batch(GraphDataStructure gds, long from, long to, int nodeAdditions,
* APPLICATION
*/
- public boolean apply(Graph g) {
+ public boolean apply(IGraph g) {
if (this.from != g.getTimestamp()) {
throw new IllegalStateException("cannot apply batch "
@@ -93,7 +93,7 @@ public boolean apply(Graph g) {
return success;
}
- private boolean apply(Graph g, Iterable extends Update> updates) {
+ private boolean apply(IGraph g, Iterable extends Update> updates) {
boolean success = true;
for (Update u : updates) {
if (!u.apply(g)) {
diff --git a/src/dna/updates/batch/BatchSanitization.java b/src/dna/updates/batch/BatchSanitization.java
index fd129c57..e9936e05 100644
--- a/src/dna/updates/batch/BatchSanitization.java
+++ b/src/dna/updates/batch/BatchSanitization.java
@@ -3,8 +3,10 @@
import java.util.HashSet;
import dna.graph.edges.DirectedEdge;
+import dna.graph.edges.DirectedBlueprintsEdge;
import dna.graph.edges.Edge;
import dna.graph.edges.UndirectedEdge;
+import dna.graph.edges.UndirectedBlueprintsEdge;
import dna.graph.nodes.Node;
import dna.updates.update.EdgeAddition;
import dna.updates.update.EdgeRemoval;
@@ -114,6 +116,12 @@ private static Node[] getNodesFromEdge(Edge e) {
} else if (e instanceof UndirectedEdge) {
return new Node[] { ((UndirectedEdge) e).getNode1(),
((UndirectedEdge) e).getNode2() };
+ }else if (e instanceof DirectedBlueprintsEdge) {
+ return new Node[] { ((DirectedBlueprintsEdge) e).getSrc(),
+ ((DirectedBlueprintsEdge) e).getDst() };
+ } else if (e instanceof UndirectedBlueprintsEdge) {
+ return new Node[] { ((UndirectedBlueprintsEdge) e).getNode1(),
+ ((UndirectedBlueprintsEdge) e).getNode2() };
} else {
Log.error("edge type '" + e.getClass().getCanonicalName()
+ "' not supported in batch sanitization");
diff --git a/src/dna/updates/generators/IBatchGenerator.java b/src/dna/updates/generators/IBatchGenerator.java
index 70d216e5..51cf3fc3 100644
--- a/src/dna/updates/generators/IBatchGenerator.java
+++ b/src/dna/updates/generators/IBatchGenerator.java
@@ -1,12 +1,12 @@
package dna.updates.generators;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
public interface IBatchGenerator {
- public Batch generate(Graph g);
+ public Batch generate(IGraph g);
public void reset();
- public boolean isFurtherBatchPossible(Graph g);
+ public boolean isFurtherBatchPossible(IGraph g);
}
diff --git a/src/dna/updates/generators/combined/CombinedGraphBatch.java b/src/dna/updates/generators/combined/CombinedGraphBatch.java
index 5a610d6c..4ab723f0 100644
--- a/src/dna/updates/generators/combined/CombinedGraphBatch.java
+++ b/src/dna/updates/generators/combined/CombinedGraphBatch.java
@@ -2,7 +2,7 @@
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.generators.GraphGenerator;
@@ -30,7 +30,7 @@ public CombinedGraphBatch(CombinedGraph gg, int intraEdges, int interEdges) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
GraphDataStructure gds = g.getGraphDatastructures();
Batch b = new Batch(gds, g.getTimestamp(), g.getTimestamp() + 1);
HashSet edges = new HashSet();
@@ -99,7 +99,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return true;
}
diff --git a/src/dna/updates/generators/evolvingNetworks/BarabasiAlbertBatch.java b/src/dna/updates/generators/evolvingNetworks/BarabasiAlbertBatch.java
index 89b9c89d..eacb419c 100644
--- a/src/dna/updates/generators/evolvingNetworks/BarabasiAlbertBatch.java
+++ b/src/dna/updates/generators/evolvingNetworks/BarabasiAlbertBatch.java
@@ -2,7 +2,7 @@
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.Node;
@@ -28,7 +28,7 @@ public BarabasiAlbertBatch(int nodes, int m) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, this.nodes, 0, 0, this.nodes * this.m, 0,
0);
@@ -114,10 +114,11 @@ public Batch generate(Graph g) {
@Override
public void reset() {
+
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return g.getNodeCount() >= this.m;
}
diff --git a/src/dna/updates/generators/evolvingNetworks/PositiveFeedbackPreferenceBatch.java b/src/dna/updates/generators/evolvingNetworks/PositiveFeedbackPreferenceBatch.java
index a263702e..2cc63be4 100644
--- a/src/dna/updates/generators/evolvingNetworks/PositiveFeedbackPreferenceBatch.java
+++ b/src/dna/updates/generators/evolvingNetworks/PositiveFeedbackPreferenceBatch.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.Random;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.nodes.DirectedNode;
import dna.graph.nodes.Node;
@@ -74,7 +74,7 @@ public PositiveFeedbackPreferenceBatch(int nodes, double delta, double p, double
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, this.nodes, 0, 0, this.nodes, 0,
0);
@@ -84,7 +84,7 @@ public Batch generate(Graph g) {
return b;
}
- private void growGraph(Graph g, Batch b) {
+ private void growGraph(IGraph g, Batch b) {
// new nodes can be targets for later nodes
Node[] newNodes = new Node[this.nodes];
int[] newDegrees = new int[this.nodes];
@@ -207,7 +207,7 @@ private void increaseDegree(int[] oldDegrees, int[] newDegrees, int maxOldIndex,
* Iterate over all nodes and calculate a valid one.
* Probability formula is given by the paper:
*
- * @param g Graph to retrieve the old nodes
+ * @param g IGraph to retrieve the old nodes
* @param oldDegrees degrees of the old nodes
* @param newNodes array with new nodes
* @param newDegrees degrees of the new nodes
@@ -217,7 +217,7 @@ private void increaseDegree(int[] oldDegrees, int[] newDegrees, int maxOldIndex,
* @param srcNode source node of this edge
* @return destination node
*/
- private Node getNPPNode(Graph g, int[] oldDegrees, Node[] newNodes, int[] newDegrees, int maxOldId, int maxId,
+ private Node getNPPNode(IGraph g, int[] oldDegrees, Node[] newNodes, int[] newDegrees, int maxOldId, int maxId,
int ignoreNode, int srcNode) {
int npp = -1;
@@ -300,7 +300,7 @@ private double calcExponent(int kj) {
* @param g current graph
* @return array of node-degrees
*/
- private int[] collectOldDegrees(Graph g) {
+ private int[] collectOldDegrees(IGraph g) {
int[] oldDegrees = new int[g.getNodeCount()];
for(IElement n : g.getNodes()){
Node node = (Node) n;
@@ -318,7 +318,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return true;
}
diff --git a/src/dna/updates/generators/evolvingNetworks/RandomGrowth.java b/src/dna/updates/generators/evolvingNetworks/RandomGrowth.java
index 9db3f5fb..d59da781 100644
--- a/src/dna/updates/generators/evolvingNetworks/RandomGrowth.java
+++ b/src/dna/updates/generators/evolvingNetworks/RandomGrowth.java
@@ -2,8 +2,8 @@
import java.util.HashSet;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.updates.batch.Batch;
@@ -27,7 +27,7 @@ public RandomGrowth(int nodes, int edgesPerNode) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, this.nodes, 0, 0, this.nodes
* this.edgesPerNode, 0, 0);
@@ -78,7 +78,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return g.getNodeCount() >= this.edgesPerNode;
}
diff --git a/src/dna/updates/generators/evolvingNetworks/RandomScalingBatch.java b/src/dna/updates/generators/evolvingNetworks/RandomScalingBatch.java
index 4879cea9..8a4163b7 100644
--- a/src/dna/updates/generators/evolvingNetworks/RandomScalingBatch.java
+++ b/src/dna/updates/generators/evolvingNetworks/RandomScalingBatch.java
@@ -1,6 +1,6 @@
package dna.updates.generators.evolvingNetworks;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
import dna.updates.generators.random.RandomBatch;
@@ -25,7 +25,7 @@ public RandomScalingBatch(double growthFactor, double shrinkFactor) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = this.getCurrentBatch(g).generate(g);
return b;
}
@@ -34,7 +34,7 @@ public Batch generate(Graph g) {
public void reset() {
}
- private RandomBatch getCurrentBatch(Graph g) {
+ private RandomBatch getCurrentBatch(IGraph g) {
int nodes = g.getNodeCount();
int edges = g.getEdgeCount();
@@ -45,7 +45,7 @@ private RandomBatch getCurrentBatch(Graph g) {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.getCurrentBatch(g).isFurtherBatchPossible(g);
}
}
diff --git a/src/dna/updates/generators/konect/KonectBatch.java b/src/dna/updates/generators/konect/KonectBatch.java
index dbf26045..73753d5a 100644
--- a/src/dna/updates/generators/konect/KonectBatch.java
+++ b/src/dna/updates/generators/konect/KonectBatch.java
@@ -1,7 +1,7 @@
package dna.updates.generators.konect;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.generators.konect.KonectEdge;
import dna.graph.generators.konect.KonectReader;
@@ -52,7 +52,7 @@ public KonectBatch(KonectReader r, KonectBatchType batchType,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1);
@@ -118,7 +118,7 @@ public Batch generate(Graph g) {
* @param b
* @param edge
*/
- protected void process(Graph graph, Batch b, KonectEdge edge) {
+ protected void process(IGraph graph, Batch b, KonectEdge edge) {
if (edge.n1 == edge.n2) {
return;
@@ -286,7 +286,7 @@ protected void process(Graph graph, Batch b, KonectEdge edge) {
}
}
- protected void processNode(Graph g, Batch b, Node n) {
+ protected void processNode(IGraph g, Batch b, Node n) {
if (g.containsNode(n)) {
NodeRemoval nr = b.getNodeRemoval(n);
if (nr != null) {
@@ -306,7 +306,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return r.peek() != null;
}
diff --git a/src/dna/updates/generators/random/GrowingRandomBatch.java b/src/dna/updates/generators/random/GrowingRandomBatch.java
index d4026293..3ca07dc6 100644
--- a/src/dna/updates/generators/random/GrowingRandomBatch.java
+++ b/src/dna/updates/generators/random/GrowingRandomBatch.java
@@ -1,6 +1,6 @@
package dna.updates.generators.random;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.weights.Weight.WeightSelection;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -34,7 +34,7 @@ public GrowingRandomBatch(RandomBatch rb) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = this.getCurrentBatch().generate(g);
this.time++;
return b;
@@ -51,7 +51,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.getCurrentBatch().isFurtherBatchPossible(g);
}
}
diff --git a/src/dna/updates/generators/random/GrowingRandomEdgeExchange.java b/src/dna/updates/generators/random/GrowingRandomEdgeExchange.java
index 7a437fc9..d8257d7d 100644
--- a/src/dna/updates/generators/random/GrowingRandomEdgeExchange.java
+++ b/src/dna/updates/generators/random/GrowingRandomEdgeExchange.java
@@ -1,6 +1,6 @@
package dna.updates.generators.random;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
import dna.util.parameters.IntParameter;
@@ -22,7 +22,7 @@ public GrowingRandomEdgeExchange(int edges, int maxFails) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = this.getCurrentBatch().generate(g);
this.time++;
return b;
@@ -38,7 +38,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.getCurrentBatch().isFurtherBatchPossible(g);
}
diff --git a/src/dna/updates/generators/random/RandomBatch.java b/src/dna/updates/generators/random/RandomBatch.java
index 972dad3e..a1abfb0f 100644
--- a/src/dna/updates/generators/random/RandomBatch.java
+++ b/src/dna/updates/generators/random/RandomBatch.java
@@ -2,7 +2,7 @@
import java.util.ArrayList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.weights.Weight.WeightSelection;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -86,7 +86,7 @@ private void init() {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, this.na, this.nr, this.nw, this.ea,
this.er, this.ew);
@@ -103,7 +103,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
for (BatchGenerator bg : this.bgs) {
if (bg.isFurtherBatchPossible(g)) {
return true;
diff --git a/src/dna/updates/generators/random/RandomEdgeAdditions.java b/src/dna/updates/generators/random/RandomEdgeAdditions.java
index 332d555a..22921155 100644
--- a/src/dna/updates/generators/random/RandomEdgeAdditions.java
+++ b/src/dna/updates/generators/random/RandomEdgeAdditions.java
@@ -3,7 +3,7 @@
import java.math.BigInteger;
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.updates.batch.Batch;
@@ -21,7 +21,7 @@ public RandomEdgeAdditions(int count) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, 0, 0, 0, this.count, 0, 0);
@@ -69,7 +69,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
int oldEdgeCount = g.getEdgeCount();
BigInteger maxEdgeCount = g.getMaxEdgeCount();
BigInteger absoluteMaximumToInsert = maxEdgeCount.subtract(BigInteger
diff --git a/src/dna/updates/generators/random/RandomEdgeExchange.java b/src/dna/updates/generators/random/RandomEdgeExchange.java
index d4d3b134..b2b2146b 100644
--- a/src/dna/updates/generators/random/RandomEdgeExchange.java
+++ b/src/dna/updates/generators/random/RandomEdgeExchange.java
@@ -2,7 +2,7 @@
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.Edge;
import dna.graph.edges.UndirectedEdge;
@@ -26,7 +26,7 @@ public RandomEdgeExchange(int edges, int maxFails) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1);
@@ -118,7 +118,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.edges < g.getEdgeCount() / 2;
}
}
diff --git a/src/dna/updates/generators/random/RandomEdgeRemovals.java b/src/dna/updates/generators/random/RandomEdgeRemovals.java
index feaa0646..5d323768 100644
--- a/src/dna/updates/generators/random/RandomEdgeRemovals.java
+++ b/src/dna/updates/generators/random/RandomEdgeRemovals.java
@@ -2,7 +2,7 @@
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -19,7 +19,7 @@ public RandomEdgeRemovals(int count) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, 0, 0, 0, 0, this.count, 0);
@@ -41,7 +41,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return g.getEdgeCount() > 0;
}
diff --git a/src/dna/updates/generators/random/RandomNodeAdditions.java b/src/dna/updates/generators/random/RandomNodeAdditions.java
index 0574d3b9..1d9e4cba 100644
--- a/src/dna/updates/generators/random/RandomNodeAdditions.java
+++ b/src/dna/updates/generators/random/RandomNodeAdditions.java
@@ -2,7 +2,7 @@
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -19,7 +19,7 @@ public RandomNodeAdditions(int count) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, this.count, 0, 0, 0, 0, 0);
@@ -39,7 +39,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return true;
}
diff --git a/src/dna/updates/generators/random/RandomNodeRemovals.java b/src/dna/updates/generators/random/RandomNodeRemovals.java
index b0eafc65..deff0ed5 100644
--- a/src/dna/updates/generators/random/RandomNodeRemovals.java
+++ b/src/dna/updates/generators/random/RandomNodeRemovals.java
@@ -2,7 +2,7 @@
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -19,7 +19,7 @@ public RandomNodeRemovals(int count) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, 0, this.count, 0, 0, 0, 0);
@@ -41,7 +41,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return g.getNodeCount() > 0;
}
diff --git a/src/dna/updates/generators/random/RandomWeightChanges.java b/src/dna/updates/generators/random/RandomWeightChanges.java
index 30a99d28..43e1c1d6 100644
--- a/src/dna/updates/generators/random/RandomWeightChanges.java
+++ b/src/dna/updates/generators/random/RandomWeightChanges.java
@@ -2,7 +2,7 @@
import java.util.HashSet;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.graph.weights.IWeightedEdge;
@@ -34,7 +34,7 @@ public RandomWeightChanges(int nodes, WeightSelection nSelection,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1, 0, 0, this.nodes, 0, 0, this.edges);
@@ -67,7 +67,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return g.getNodeCount() >= this.nodes && g.getEdgeCount() >= this.edges;
}
diff --git a/src/dna/updates/generators/sampling/BFS.java b/src/dna/updates/generators/sampling/BFS.java
index c22bfcc7..3aec9702 100644
--- a/src/dna/updates/generators/sampling/BFS.java
+++ b/src/dna/updates/generators/sampling/BFS.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
@@ -36,13 +36,12 @@ public class BFS extends SamplingAlgorithm {
* @param parameters
* the parameters which makes this algorithm unique and which
* will be added to the name
- */
- public BFS(Graph fullGraph, StartNodeSelectionStrategy startNodeStrategy,
+ */
+ public BFS(IGraph fullGraph, StartNodeSelectionStrategy startNodeStrategy,
int costPerBatch, int resource, SamplingStop stop,
WalkingType walkingType) {
super("BFS", fullGraph, startNodeStrategy, costPerBatch, resource,
stop, walkingType);
-
queue = new LinkedList();
nodesInQueue = new HashSet();
currentNode = null;
diff --git a/src/dna/updates/generators/sampling/DFS.java b/src/dna/updates/generators/sampling/DFS.java
index 15bc3a2c..34f7870b 100644
--- a/src/dna/updates/generators/sampling/DFS.java
+++ b/src/dna/updates/generators/sampling/DFS.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
@@ -36,12 +36,12 @@ public class DFS extends SamplingAlgorithm {
* @param parameters
* the parameters which makes this algorithm unique and which
* will be added to the name
- */
- public DFS(Graph fullGraph, StartNodeSelectionStrategy startNodeStrategy,
+ */
+ public DFS(IGraph fullGraph, StartNodeSelectionStrategy startNodeStrategy,
int costPerBatch, int resource, SamplingStop stop,
WalkingType walkingType) {
super("DFS", fullGraph, startNodeStrategy, costPerBatch, resource,
- stop, walkingType);
+ stop, walkingType);
queue = new LinkedList();
nodesInQueue = new HashSet();
diff --git a/src/dna/updates/generators/sampling/DFS_Jump.java b/src/dna/updates/generators/sampling/DFS_Jump.java
index 758be69d..e063b0f9 100644
--- a/src/dna/updates/generators/sampling/DFS_Jump.java
+++ b/src/dna/updates/generators/sampling/DFS_Jump.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
@@ -37,7 +37,7 @@ public class DFS_Jump extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public DFS_Jump(Graph fullGraph,
+ public DFS_Jump(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("DFS_Jump", fullGraph, startNodeStrategy, costPerBatch, resource,
diff --git a/src/dna/updates/generators/sampling/DFS_random.java b/src/dna/updates/generators/sampling/DFS_random.java
index 01f1f653..33b32b17 100644
--- a/src/dna/updates/generators/sampling/DFS_random.java
+++ b/src/dna/updates/generators/sampling/DFS_random.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -42,7 +42,7 @@ public class DFS_random extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public DFS_random(Graph fullGraph,
+ public DFS_random(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("DFS_random", fullGraph, startNodeStrategy, costPerBatch,
diff --git a/src/dna/updates/generators/sampling/DFS_random_Jump.java b/src/dna/updates/generators/sampling/DFS_random_Jump.java
index feb90bef..f5e08631 100644
--- a/src/dna/updates/generators/sampling/DFS_random_Jump.java
+++ b/src/dna/updates/generators/sampling/DFS_random_Jump.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -42,7 +42,7 @@ public class DFS_random_Jump extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public DFS_random_Jump(Graph fullGraph,
+ public DFS_random_Jump(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("DFS_random_Jump", fullGraph, startNodeStrategy, costPerBatch,
diff --git a/src/dna/updates/generators/sampling/ForestFire.java b/src/dna/updates/generators/sampling/ForestFire.java
index ed4ac374..a48b52e6 100644
--- a/src/dna/updates/generators/sampling/ForestFire.java
+++ b/src/dna/updates/generators/sampling/ForestFire.java
@@ -3,7 +3,7 @@
import java.util.LinkedList;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
import dna.util.Rand;
@@ -40,7 +40,7 @@ public class ForestFire extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public ForestFire(Graph fullGraph,
+ public ForestFire(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, double probability, SamplingStop stop,
WalkingType walkingType) throws Exception {
diff --git a/src/dna/updates/generators/sampling/ForestFireNR.java b/src/dna/updates/generators/sampling/ForestFireNR.java
index b8ff7b0e..c261ed50 100644
--- a/src/dna/updates/generators/sampling/ForestFireNR.java
+++ b/src/dna/updates/generators/sampling/ForestFireNR.java
@@ -5,7 +5,7 @@
import java.util.LinkedList;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
import dna.util.Rand;
@@ -46,7 +46,7 @@ public class ForestFireNR extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public ForestFireNR(Graph fullGraph,
+ public ForestFireNR(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, double probability, SamplingStop stop,
WalkingType walkingType) throws Exception {
diff --git a/src/dna/updates/generators/sampling/FrontierSampling.java b/src/dna/updates/generators/sampling/FrontierSampling.java
index 43b41378..376c8b38 100644
--- a/src/dna/updates/generators/sampling/FrontierSampling.java
+++ b/src/dna/updates/generators/sampling/FrontierSampling.java
@@ -5,7 +5,7 @@
import java.util.Iterator;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.RandomSelection;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
@@ -47,7 +47,7 @@ public class FrontierSampling extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public FrontierSampling(Graph fullGraph,
+ public FrontierSampling(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, int numberOfWalkers, SamplingStop stop,
WalkingType walkingType) {
diff --git a/src/dna/updates/generators/sampling/GreedyOracle.java b/src/dna/updates/generators/sampling/GreedyOracle.java
index 971ef936..50e1ef4a 100644
--- a/src/dna/updates/generators/sampling/GreedyOracle.java
+++ b/src/dna/updates/generators/sampling/GreedyOracle.java
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.Collections;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.SortableNode.SortType;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
@@ -38,7 +38,7 @@ public class GreedyOracle extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public GreedyOracle(Graph fullGraph,
+ public GreedyOracle(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("GO", fullGraph, startNodeStrategy, costPerBatch, resource, stop,
diff --git a/src/dna/updates/generators/sampling/MaximumObservedDegree.java b/src/dna/updates/generators/sampling/MaximumObservedDegree.java
index e1cf9fda..b3fc70fa 100644
--- a/src/dna/updates/generators/sampling/MaximumObservedDegree.java
+++ b/src/dna/updates/generators/sampling/MaximumObservedDegree.java
@@ -6,7 +6,7 @@
import java.util.Map;
import java.util.TreeMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
@@ -41,7 +41,7 @@ public class MaximumObservedDegree extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public MaximumObservedDegree(Graph fullGraph,
+ public MaximumObservedDegree(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("MOD", fullGraph, startNodeStrategy, costPerBatch, resource,
diff --git a/src/dna/updates/generators/sampling/RandomWalk.java b/src/dna/updates/generators/sampling/RandomWalk.java
index 4f4aadd2..e4b82b13 100644
--- a/src/dna/updates/generators/sampling/RandomWalk.java
+++ b/src/dna/updates/generators/sampling/RandomWalk.java
@@ -2,7 +2,7 @@
import java.util.ArrayList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
import dna.util.Rand;
@@ -36,7 +36,7 @@ public class RandomWalk extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public RandomWalk(Graph fullGraph,
+ public RandomWalk(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("RW", fullGraph, startNodeStrategy, costPerBatch, resource, stop,
diff --git a/src/dna/updates/generators/sampling/RandomWalkNR.java b/src/dna/updates/generators/sampling/RandomWalkNR.java
index 4e3c27ea..3a4726a9 100644
--- a/src/dna/updates/generators/sampling/RandomWalkNR.java
+++ b/src/dna/updates/generators/sampling/RandomWalkNR.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.Iterator;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
import dna.util.Rand;
@@ -41,7 +41,7 @@ public class RandomWalkNR extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public RandomWalkNR(Graph fullGraph,
+ public RandomWalkNR(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("RWnr", fullGraph, startNodeStrategy, costPerBatch, resource,
diff --git a/src/dna/updates/generators/sampling/RandomWalkNR_Jump.java b/src/dna/updates/generators/sampling/RandomWalkNR_Jump.java
index 5ce03c05..6b9a78ca 100644
--- a/src/dna/updates/generators/sampling/RandomWalkNR_Jump.java
+++ b/src/dna/updates/generators/sampling/RandomWalkNR_Jump.java
@@ -4,7 +4,7 @@
import java.util.HashSet;
import java.util.Iterator;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
import dna.util.Rand;
@@ -41,7 +41,7 @@ public class RandomWalkNR_Jump extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public RandomWalkNR_Jump(Graph fullGraph,
+ public RandomWalkNR_Jump(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("RWnr_Jump", fullGraph, startNodeStrategy, costPerBatch,
diff --git a/src/dna/updates/generators/sampling/RespondentDrivenSampling.java b/src/dna/updates/generators/sampling/RespondentDrivenSampling.java
index c3cce228..e94e0195 100644
--- a/src/dna/updates/generators/sampling/RespondentDrivenSampling.java
+++ b/src/dna/updates/generators/sampling/RespondentDrivenSampling.java
@@ -3,7 +3,7 @@
import java.util.LinkedList;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
import dna.util.Rand;
@@ -44,7 +44,7 @@ public class RespondentDrivenSampling extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public RespondentDrivenSampling(Graph fullGraph,
+ public RespondentDrivenSampling(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, int numberOfNeighborsVisited, SamplingStop stop,
WalkingType walkingType) {
diff --git a/src/dna/updates/generators/sampling/SamplingAlgorithm.java b/src/dna/updates/generators/sampling/SamplingAlgorithm.java
index 04b02c70..885bc4eb 100644
--- a/src/dna/updates/generators/sampling/SamplingAlgorithm.java
+++ b/src/dna/updates/generators/sampling/SamplingAlgorithm.java
@@ -5,8 +5,8 @@
import java.util.HashSet;
import java.util.List;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.Edge;
@@ -36,7 +36,7 @@ public abstract class SamplingAlgorithm extends BatchGenerator {
private HashMap addedNodes;
- protected Graph fullGraph;
+ protected IGraph fullGraph;
private StartNodeSelectionStrategy startNodeStartegy;
@@ -82,7 +82,7 @@ public static enum WalkingType {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public SamplingAlgorithm(String name, Graph fullGraph,
+ public SamplingAlgorithm(String name, IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop samplingStop, WalkingType walkingType) {
super(name, new Parameter[] {
@@ -127,7 +127,7 @@ public SamplingAlgorithm(String name, Graph fullGraph,
* @param g
* the current sample
*/
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch newBatch = new Batch(g.getGraphDatastructures(),
g.getTimestamp(), g.getTimestamp() + 1);
@@ -199,7 +199,7 @@ public Batch generate(Graph g) {
* added to the batch but are not yet added to the sample
* @return the current batch
*/
- private Batch addNodeAndNeighborsToBatch(Batch batch, Node node, Graph g) {
+ private Batch addNodeAndNeighborsToBatch(Batch batch, Node node, IGraph g) {
if (noFurtherBatch) {
return batch;
@@ -242,8 +242,8 @@ private Batch addNodeAndNeighborsToBatch(Batch batch, Node node, Graph g) {
* added to the batch but are not yet added to the sample
* @return a list of node and edge additions
*/
- private List addNeighbors(Node nodeFromFullGraph, Node newNode,
- Graph g) {
+ private List addNeighbors(Node nodeFromFullGraph, Node newNode,
+ IGraph g) {
List updateList = new ArrayList();
// Iterable iter = getEdgesFromNode(nodeFromFullGraph);
@@ -295,7 +295,7 @@ private List addNeighbors(Node nodeFromFullGraph, Node newNode,
/**
* Returns if the sampling algorithm can walk further through the graph
*/
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
if (takeResourceIntoAccount && resource <= 0) {
return false;
@@ -541,7 +541,7 @@ protected long getTimeStamp() {
*
* @return full graph from which the sampling is done
*/
- public Graph getFullGraph() {
+ public IGraph getFullGraph() {
return fullGraph;
}
diff --git a/src/dna/updates/generators/sampling/SnowballSampling.java b/src/dna/updates/generators/sampling/SnowballSampling.java
index fa944bff..05f13654 100644
--- a/src/dna/updates/generators/sampling/SnowballSampling.java
+++ b/src/dna/updates/generators/sampling/SnowballSampling.java
@@ -5,7 +5,7 @@
import java.util.LinkedList;
import java.util.List;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
import dna.util.Rand;
@@ -47,7 +47,7 @@ public class SnowballSampling extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public SnowballSampling(Graph fullGraph,
+ public SnowballSampling(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, int numberOfNeighborsVisited, SamplingStop stop,
WalkingType walkingType) {
diff --git a/src/dna/updates/generators/sampling/UniformSampling.java b/src/dna/updates/generators/sampling/UniformSampling.java
index 2f3f2203..97e276c7 100644
--- a/src/dna/updates/generators/sampling/UniformSampling.java
+++ b/src/dna/updates/generators/sampling/UniformSampling.java
@@ -3,7 +3,7 @@
import java.util.Iterator;
import java.util.LinkedList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.nodes.Node;
import dna.updates.generators.sampling.startNode.StartNodeSelectionStrategy;
@@ -37,7 +37,7 @@ public class UniformSampling extends SamplingAlgorithm {
* the parameters which makes this algorithm unique and which
* will be added to the name
*/
- public UniformSampling(Graph fullGraph,
+ public UniformSampling(IGraph fullGraph,
StartNodeSelectionStrategy startNodeStrategy, int costPerBatch,
int resource, SamplingStop stop, WalkingType walkingType) {
super("US", fullGraph, startNodeStrategy, costPerBatch, resource, stop,
diff --git a/src/dna/updates/generators/sampling/startNode/HighestDegreeSelection.java b/src/dna/updates/generators/sampling/startNode/HighestDegreeSelection.java
index 18b42ad0..8ab8c875 100644
--- a/src/dna/updates/generators/sampling/startNode/HighestDegreeSelection.java
+++ b/src/dna/updates/generators/sampling/startNode/HighestDegreeSelection.java
@@ -1,6 +1,6 @@
package dna.updates.generators.sampling.startNode;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.nodes.Node;
@@ -22,7 +22,7 @@ public HighestDegreeSelection() {
}
@Override
- public Node getStartNode(Graph g) {
+ public Node getStartNode(IGraph g) {
Node startNode = null;
int maxDegree = 0;
@@ -39,7 +39,7 @@ public Node getStartNode(Graph g) {
}
@Override
- public int resourceCost(Graph g) {
+ public int resourceCost(IGraph g) {
return g.getNodeCount();
}
diff --git a/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSelection.java b/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSelection.java
index 526f7904..76235ad5 100644
--- a/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSelection.java
+++ b/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSelection.java
@@ -1,6 +1,6 @@
package dna.updates.generators.sampling.startNode;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
/**
@@ -27,7 +27,7 @@ public HighestRandomDegreeSelection(int n) {
}
@Override
- public Node getStartNode(Graph g) {
+ public Node getStartNode(IGraph g) {
int maxDegree = 0;
@@ -48,7 +48,7 @@ public Node getStartNode(Graph g) {
}
@Override
- public int resourceCost(Graph g) {
+ public int resourceCost(IGraph g) {
return n;
}
diff --git a/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSumSelection.java b/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSumSelection.java
index 5be62304..0ee58b89 100644
--- a/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSumSelection.java
+++ b/src/dna/updates/generators/sampling/startNode/HighestRandomDegreeSumSelection.java
@@ -2,7 +2,7 @@
import java.util.ArrayList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.util.Rand;
@@ -38,7 +38,7 @@ public HighestRandomDegreeSumSelection(int numberOfNodes,
}
@Override
- public Node getStartNode(Graph g) {
+ public Node getStartNode(IGraph g) {
int maxDegreeSum = 0;
@@ -76,7 +76,7 @@ public Node getStartNode(Graph g) {
}
@Override
- public int resourceCost(Graph g) {
+ public int resourceCost(IGraph g) {
return n * m;
}
diff --git a/src/dna/updates/generators/sampling/startNode/NodeSelection.java b/src/dna/updates/generators/sampling/startNode/NodeSelection.java
index 4ced3ffc..689c0594 100644
--- a/src/dna/updates/generators/sampling/startNode/NodeSelection.java
+++ b/src/dna/updates/generators/sampling/startNode/NodeSelection.java
@@ -1,6 +1,6 @@
package dna.updates.generators.sampling.startNode;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
/**
@@ -27,12 +27,12 @@ public NodeSelection(int id) {
}
@Override
- public Node getStartNode(Graph g) {
+ public Node getStartNode(IGraph g) {
return g.getNode(id);
}
@Override
- public int resourceCost(Graph g) {
+ public int resourceCost(IGraph g) {
return 1;
}
diff --git a/src/dna/updates/generators/sampling/startNode/NodeValueListSelection.java b/src/dna/updates/generators/sampling/startNode/NodeValueListSelection.java
index 944a6199..cbd00561 100644
--- a/src/dna/updates/generators/sampling/startNode/NodeValueListSelection.java
+++ b/src/dna/updates/generators/sampling/startNode/NodeValueListSelection.java
@@ -2,7 +2,7 @@
import java.util.Arrays;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
import dna.plot.data.PlotData.NodeValueListOrderBy;
import dna.series.data.nodevaluelists.NodeValueList;
@@ -41,7 +41,7 @@ public NodeValueListSelection(NodeValueList nvl,
}
@Override
- public Node getStartNode(Graph g) {
+ public Node getStartNode(IGraph g) {
if (nvlOrder == NodeValueListOrderBy.median) {
return selectMedian(g);
} else if (nvlOrder == NodeValueListOrderBy.maximum) {
@@ -52,14 +52,14 @@ public Node getStartNode(Graph g) {
}
@Override
- public int resourceCost(Graph g) {
+ public int resourceCost(IGraph g) {
return nvl.length;
}
/**
* Selects the node with the median value of the NodeValueList
*/
- private Node selectMedian(Graph g) {
+ private Node selectMedian(IGraph g) {
int index = 0;
double[] tempArr = new double[nvl.length];
for (int i = 0; i < nvl.length; i++) {
@@ -81,7 +81,7 @@ private Node selectMedian(Graph g) {
/**
* Selects the node with the maximal value of the NodeValueList
*/
- private Node selectMaximum(Graph g) {
+ private Node selectMaximum(IGraph g) {
double tempVal = Double.MIN_VALUE;
int index = 0;
for (int i = 0; i < nvl.length; i++) {
@@ -96,7 +96,7 @@ private Node selectMaximum(Graph g) {
/**
* Selects the node with the minimal value of the NodeValueList
*/
- private Node selectMinimum(Graph g) {
+ private Node selectMinimum(IGraph g) {
double tempVal = Double.MAX_VALUE;
int index = 0;
for (int i = 0; i < nvl.length; i++) {
diff --git a/src/dna/updates/generators/sampling/startNode/RandomSelection.java b/src/dna/updates/generators/sampling/startNode/RandomSelection.java
index c4019433..61bffa9f 100644
--- a/src/dna/updates/generators/sampling/startNode/RandomSelection.java
+++ b/src/dna/updates/generators/sampling/startNode/RandomSelection.java
@@ -1,6 +1,6 @@
package dna.updates.generators.sampling.startNode;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.nodes.Node;
/**
@@ -20,12 +20,12 @@ public RandomSelection() {
}
@Override
- public Node getStartNode(Graph g) {
+ public Node getStartNode(IGraph g) {
return g.getRandomNode();
}
@Override
- public int resourceCost(Graph g) {
+ public int resourceCost(IGraph g) {
return 1;
}
diff --git a/src/dna/updates/generators/sampling/startNode/StartNodeSelectionStrategy.java b/src/dna/updates/generators/sampling/startNode/StartNodeSelectionStrategy.java
index 71de253c..5d8fc9cb 100644
--- a/src/dna/updates/generators/sampling/startNode/StartNodeSelectionStrategy.java
+++ b/src/dna/updates/generators/sampling/startNode/StartNodeSelectionStrategy.java
@@ -2,7 +2,7 @@
import java.util.ArrayList;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.Edge;
import dna.graph.nodes.DirectedNode;
@@ -29,12 +29,12 @@ public StartNodeSelectionStrategy() {
/**
* Returns a start node based on the specific node selection strategy
*/
- public abstract Node getStartNode(Graph g);
+ public abstract Node getStartNode(IGraph g);
/**
* Returns the resource costs for the specific strategy
*/
- public abstract int resourceCost(Graph g);
+ public abstract int resourceCost(IGraph g);
/**
* Returns a list of all neighbors of node n
diff --git a/src/dna/updates/generators/timestamped/TimestampedBatch.java b/src/dna/updates/generators/timestamped/TimestampedBatch.java
index 6d1ce2dc..0769e47a 100644
--- a/src/dna/updates/generators/timestamped/TimestampedBatch.java
+++ b/src/dna/updates/generators/timestamped/TimestampedBatch.java
@@ -2,7 +2,7 @@
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.generators.timestamped.TimestampedEdge;
import dna.graph.generators.timestamped.TimestampedReader;
@@ -81,7 +81,7 @@ public TimestampedBatch(TimestampedReader reader,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = new Batch(g.getGraphDatastructures(), g.getTimestamp(), -1);
TimestampedEdge e = null;
int duplicateEdges = 0;
@@ -159,7 +159,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.reader.hasMoreEdges(this.maxTimestamp);
}
diff --git a/src/dna/updates/generators/util/BatchCombinator.java b/src/dna/updates/generators/util/BatchCombinator.java
index 53c34a53..b201aa49 100644
--- a/src/dna/updates/generators/util/BatchCombinator.java
+++ b/src/dna/updates/generators/util/BatchCombinator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -14,7 +14,7 @@ public BatchCombinator(BatchGenerator... bgs) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
int addN = 0;
int remN = 0;
int weightN = 0;
@@ -49,7 +49,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
for (BatchGenerator bg : this.bgs) {
if (bg.isFurtherBatchPossible(g)) {
return true;
diff --git a/src/dna/updates/generators/util/BatchRepetition.java b/src/dna/updates/generators/util/BatchRepetition.java
index e03a1942..20cfea28 100644
--- a/src/dna/updates/generators/util/BatchRepetition.java
+++ b/src/dna/updates/generators/util/BatchRepetition.java
@@ -1,6 +1,6 @@
package dna.updates.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -36,7 +36,7 @@ public BatchRepetition(BatchRepetitionWrapper... bgs) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = this.getNext().generate(g);
this.index = (index + 1) % this.total;
return b;
@@ -59,7 +59,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.getNext().isFurtherBatchPossible(g);
}
diff --git a/src/dna/updates/generators/util/BatchRoundRobin.java b/src/dna/updates/generators/util/BatchRoundRobin.java
index 31db0ee9..951454c9 100644
--- a/src/dna/updates/generators/util/BatchRoundRobin.java
+++ b/src/dna/updates/generators/util/BatchRoundRobin.java
@@ -1,6 +1,6 @@
package dna.updates.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -16,7 +16,7 @@ public BatchRoundRobin(BatchGenerator... bgs) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = this.bgs[this.index].generate(g);
this.index = (this.index + 1) % this.bgs.length;
return b;
@@ -28,7 +28,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.bgs[this.index].isFurtherBatchPossible(g);
}
diff --git a/src/dna/updates/generators/util/BatchWeights.java b/src/dna/updates/generators/util/BatchWeights.java
index 1d830fe9..872706cd 100644
--- a/src/dna/updates/generators/util/BatchWeights.java
+++ b/src/dna/updates/generators/util/BatchWeights.java
@@ -1,6 +1,6 @@
package dna.updates.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.weights.IWeighted;
import dna.graph.weights.Weight;
@@ -30,7 +30,7 @@ public BatchWeights(BatchGenerator bg, WeightSelection nw,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = this.bg.generate(g);
GraphDataStructure gds = g.getGraphDatastructures();
@@ -56,7 +56,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.bg.isFurtherBatchPossible(g);
}
diff --git a/src/dna/updates/generators/util/EmptyBatch.java b/src/dna/updates/generators/util/EmptyBatch.java
index bdfc0944..2bf0c609 100644
--- a/src/dna/updates/generators/util/EmptyBatch.java
+++ b/src/dna/updates/generators/util/EmptyBatch.java
@@ -1,6 +1,6 @@
package dna.updates.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -11,7 +11,7 @@ public EmptyBatch() {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
return new Batch(g.getGraphDatastructures(), g.getTimestamp(),
g.getTimestamp() + 1);
}
@@ -21,7 +21,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return true;
}
diff --git a/src/dna/updates/generators/util/LegacyReadableDirBatchGenerator.java b/src/dna/updates/generators/util/LegacyReadableDirBatchGenerator.java
index adac81aa..f7b65dfb 100644
--- a/src/dna/updates/generators/util/LegacyReadableDirBatchGenerator.java
+++ b/src/dna/updates/generators/util/LegacyReadableDirBatchGenerator.java
@@ -2,7 +2,7 @@
import java.io.FilenameFilter;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.io.LegacyBatchReader;
import dna.updates.batch.Batch;
@@ -18,7 +18,7 @@ public LegacyReadableDirBatchGenerator(String name, String dir,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
return LegacyBatchReader.read(dir, this.filenames[this.index++], g);
}
diff --git a/src/dna/updates/generators/util/LegacyReadableFilesBatchGenerator.java b/src/dna/updates/generators/util/LegacyReadableFilesBatchGenerator.java
index 09dc1029..e0ffc080 100644
--- a/src/dna/updates/generators/util/LegacyReadableFilesBatchGenerator.java
+++ b/src/dna/updates/generators/util/LegacyReadableFilesBatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.io.LegacyBatchReader;
import dna.updates.batch.Batch;
@@ -13,7 +13,7 @@ public LegacyReadableFilesBatchGenerator(String dir, String prefix,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
return LegacyBatchReader.read(this.dir, this.getFilename(g), g);
}
diff --git a/src/dna/updates/generators/util/ReadableDirBatchGenerator.java b/src/dna/updates/generators/util/ReadableDirBatchGenerator.java
index e6a4704e..329a06d5 100644
--- a/src/dna/updates/generators/util/ReadableDirBatchGenerator.java
+++ b/src/dna/updates/generators/util/ReadableDirBatchGenerator.java
@@ -6,7 +6,7 @@
import java.util.Comparator;
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.io.BatchReader;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -61,7 +61,7 @@ public ReadableDirBatchGenerator(String name, String dir,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
return BatchReader.read(dir, this.filenames[this.index++], g);
}
@@ -71,7 +71,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return index < this.filenames.length;
}
diff --git a/src/dna/updates/generators/util/ReadableDirConsecutiveBatchGenerator.java b/src/dna/updates/generators/util/ReadableDirConsecutiveBatchGenerator.java
index 93e2f411..810de7c5 100644
--- a/src/dna/updates/generators/util/ReadableDirConsecutiveBatchGenerator.java
+++ b/src/dna/updates/generators/util/ReadableDirConsecutiveBatchGenerator.java
@@ -2,7 +2,7 @@
import java.io.File;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.io.BatchReader;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -20,7 +20,7 @@ public ReadableDirConsecutiveBatchGenerator(String name, String dir,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
return BatchReader.read(this.dir, (g.getTimestamp() + 1) + suffix, g);
}
@@ -29,7 +29,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return ((new File(dir + (g.getTimestamp() + 1) + this.suffix)))
.exists();
}
diff --git a/src/dna/updates/generators/util/ReadableFilesBatchGenerator.java b/src/dna/updates/generators/util/ReadableFilesBatchGenerator.java
index 1e775410..0b1cd0a7 100644
--- a/src/dna/updates/generators/util/ReadableFilesBatchGenerator.java
+++ b/src/dna/updates/generators/util/ReadableFilesBatchGenerator.java
@@ -2,7 +2,7 @@
import java.io.File;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.io.BatchReader;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
@@ -40,11 +40,11 @@ public ReadableFilesBatchGenerator(String dir, String prefix,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
return BatchReader.read(this.dir, this.getFilename(g), g);
}
- protected String getFilename(Graph g) {
+ protected String getFilename(IGraph g) {
switch (this.filenameType) {
case CURRENT_TIMESTAMP:
return this.prefix + g.getTimestamp() + this.suffix;
@@ -60,7 +60,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return (new File(this.dir + this.getFilename(g))).exists();
}
diff --git a/src/dna/updates/generators/util/Timestamped.java b/src/dna/updates/generators/util/Timestamped.java
index b93e756f..1ce922df 100644
--- a/src/dna/updates/generators/util/Timestamped.java
+++ b/src/dna/updates/generators/util/Timestamped.java
@@ -1,6 +1,6 @@
package dna.updates.generators.util;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.updates.batch.Batch;
import dna.updates.generators.BatchGenerator;
import dna.util.ArrayUtils;
@@ -20,7 +20,7 @@ public Timestamped(BatchGenerator bg, int add) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
Batch b = this.bg.generate(g);
b.setTo(b.getFrom() + this.add);
return b;
@@ -31,7 +31,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return this.bg.isFurtherBatchPossible(g);
}
diff --git a/src/dna/updates/generators/weights/NodeWeightContractionAndExpansion.java b/src/dna/updates/generators/weights/NodeWeightContractionAndExpansion.java
index b7cf6091..d84a35f2 100644
--- a/src/dna/updates/generators/weights/NodeWeightContractionAndExpansion.java
+++ b/src/dna/updates/generators/weights/NodeWeightContractionAndExpansion.java
@@ -1,7 +1,7 @@
package dna.updates.generators.weights;
-import dna.graph.Graph;
import dna.graph.IElement;
+import dna.graph.IGraph;
import dna.graph.weights.IWeightedNode;
import dna.graph.weights.Weight;
import dna.graph.weights.doubleW.Double2dWeight;
@@ -38,7 +38,7 @@ public NodeWeightContractionAndExpansion(double contraction,
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
double factor;
if (this.step < this.contractionSteps) {
factor = this.contraction;
@@ -78,7 +78,7 @@ public void reset() {
}
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return g.getGraphDatastructures().isNodeType(IWeightedNode.class)
&& g.getGraphDatastructures().isNodeWeightType(
DoubleWeight.class, Double2dWeight.class,
diff --git a/src/dna/updates/generators/zalando/CustomersBrandsBatchGenerator.java b/src/dna/updates/generators/zalando/CustomersBrandsBatchGenerator.java
index 89be2859..11a03090 100644
--- a/src/dna/updates/generators/zalando/CustomersBrandsBatchGenerator.java
+++ b/src/dna/updates/generators/zalando/CustomersBrandsBatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.zalando;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.generators.zalando.data.Event;
@@ -50,7 +50,7 @@ public CustomersBrandsBatchGenerator(ZalandoGraphDataStructure gds,
* brands.
*/
@Override
- void addEdgesForColumns(Graph g, Event event) {
+ void addEdgesForColumns(IGraph g, Event event) {
int nodeForEventIndex, mappingForColumnGroup;
nodeForEventIndex = this.mappings.getMapping(
this.columnGroupsToAddAsNodes[0], event);
diff --git a/src/dna/updates/generators/zalando/CustomersCategory4BatchGenerator.java b/src/dna/updates/generators/zalando/CustomersCategory4BatchGenerator.java
index 4265cb3c..cc6954c6 100644
--- a/src/dna/updates/generators/zalando/CustomersCategory4BatchGenerator.java
+++ b/src/dna/updates/generators/zalando/CustomersCategory4BatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.zalando;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.generators.zalando.data.Event;
@@ -50,7 +50,7 @@ public CustomersCategory4BatchGenerator(ZalandoGraphDataStructure gds,
* categories.
*/
@Override
- void addEdgesForColumns(Graph g, Event event) {
+ void addEdgesForColumns(IGraph g, Event event) {
int nodeForEventIndex, mappingForColumnGroup;
nodeForEventIndex = this.mappings.getMapping(
this.columnGroupsToAddAsNodes[0], event);
diff --git a/src/dna/updates/generators/zalando/CustomersProductsBatchGenerator.java b/src/dna/updates/generators/zalando/CustomersProductsBatchGenerator.java
index 8c8e7bf3..8d592a2a 100644
--- a/src/dna/updates/generators/zalando/CustomersProductsBatchGenerator.java
+++ b/src/dna/updates/generators/zalando/CustomersProductsBatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.zalando;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.generators.zalando.data.Event;
@@ -50,7 +50,7 @@ public CustomersProductsBatchGenerator(ZalandoGraphDataStructure gds,
* products.
*/
@Override
- void addEdgesForColumns(Graph g, Event event) {
+ void addEdgesForColumns(IGraph g, Event event) {
int nodeForEventIndex, mappingForColumnGroup;
nodeForEventIndex = this.mappings.getMapping(
this.columnGroupsToAddAsNodes[0], event);
diff --git a/src/dna/updates/generators/zalando/ProductsActionsChronologyBatchGenerator.java b/src/dna/updates/generators/zalando/ProductsActionsChronologyBatchGenerator.java
index 31c356db..bf99ce58 100644
--- a/src/dna/updates/generators/zalando/ProductsActionsChronologyBatchGenerator.java
+++ b/src/dna/updates/generators/zalando/ProductsActionsChronologyBatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.zalando;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.generators.zalando.data.Event;
@@ -51,7 +51,7 @@ public ProductsActionsChronologyBatchGenerator(
* added.
*/
@Override
- void addEdgesForColumns(Graph g, Event event) {
+ void addEdgesForColumns(IGraph g, Event event) {
int nodeForEventIndex, mappingForColumnGroup;
nodeForEventIndex = this.mappings.getMapping(
this.columnGroupsToAddAsNodes[0], event);
diff --git a/src/dna/updates/generators/zalando/SessionsCategory4BatchGenerator.java b/src/dna/updates/generators/zalando/SessionsCategory4BatchGenerator.java
index 280f5029..051832e5 100644
--- a/src/dna/updates/generators/zalando/SessionsCategory4BatchGenerator.java
+++ b/src/dna/updates/generators/zalando/SessionsCategory4BatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.zalando;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.generators.zalando.data.Event;
@@ -50,8 +50,7 @@ public SessionsCategory4BatchGenerator(ZalandoGraphDataStructure gds,
* category4.
*/
@Override
- void addEdgesForColumns(Graph g, Event event) {
-
+ void addEdgesForColumns(IGraph g, Event event) {
int nodeForEventIndex, mappingForColumnGroup;
nodeForEventIndex = this.mappings.getMapping(
this.columnGroupsToAddAsNodes[0], event);
diff --git a/src/dna/updates/generators/zalando/ZalandoBatchGenerator.java b/src/dna/updates/generators/zalando/ZalandoBatchGenerator.java
index e286f993..f47481be 100644
--- a/src/dna/updates/generators/zalando/ZalandoBatchGenerator.java
+++ b/src/dna/updates/generators/zalando/ZalandoBatchGenerator.java
@@ -6,7 +6,7 @@
import java.util.HashMap;
import java.util.Map;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.edges.DirectedWeightedEdge;
@@ -136,7 +136,7 @@ public abstract class ZalandoBatchGenerator extends BatchGenerator {
// fields for batches
/**
- * The total number of {@link #generate(Graph)}-calls, e.g. used to set the
+ * The total number of {@link #generate(IGraph)}-calls, e.g. used to set the
* right timestamp.
*/
private int numberOfRuns;
@@ -340,7 +340,7 @@ public ZalandoBatchGenerator(String name, ZalandoGraphDataStructure gds,
* this edge already, the weight of this edge is increased by given weight.
*
* Instead of adding the edge directly to the graph, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -352,7 +352,7 @@ public ZalandoBatchGenerator(String name, ZalandoGraphDataStructure gds,
* The weight of the edge to add or -if the edge already exists-
* the weight added to the current weight of the existing edge.
*/
- private void addDirectedEdge(Graph g, Node source, Node target,
+ private void addDirectedEdge(IGraph g, Node source, Node target,
double weight) {
final Edge edge = g.getGraphDatastructures().newEdgeInstance(source,
target);
@@ -392,7 +392,7 @@ private void addDirectedEdge(Graph g, Node source, Node target,
* this edge already, the weight of this edge is increased by given weight.
*
* Instead of adding the edge directly to the graph, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -404,7 +404,7 @@ private void addDirectedEdge(Graph g, Node source, Node target,
* The weight of the edge to add or -if the edge already exists-
* the weight added to the current weight of the existing edge.
*/
- private void addDirectedEdge(Graph g, Node source, Node target, int weight) {
+ private void addDirectedEdge(IGraph g, Node source, Node target, int weight) {
final Edge edge = g.getGraphDatastructures().newEdgeInstance(source,
target);
@@ -445,7 +445,7 @@ private void addDirectedEdge(Graph g, Node source, Node target, int weight) {
* already, the weight of this edge is increased by given weight.
*
* Instead of adding the edge directly to the graph, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -459,7 +459,7 @@ private void addDirectedEdge(Graph g, Node source, Node target, int weight) {
* Depending on the {@link GraphDataStructure} the weight will be
* casted to an {@code int} or {@code double} value.
*/
- void addEdge(Graph g, Node source, Node target, Object weight) {
+ void addEdge(IGraph g, Node source, Node target, Object weight) {
final Class extends Edge> edgeType = g.getGraphDatastructures()
.getEdgeType();
final Class extends Weight> edgeWeightType = g
@@ -483,7 +483,7 @@ else if (edgeType.equals(UndirectedWeightedEdge.class)
Integer.valueOf(weight.toString()));
}
- abstract void addEdgesForColumns(Graph g, Event currentEvent);
+ abstract void addEdgesForColumns(IGraph g, Event currentEvent);
/**
* Adds the {@link Node}s for given {@link Old_Event} to given graph.
@@ -494,14 +494,14 @@ else if (edgeType.equals(UndirectedWeightedEdge.class)
*
*
* Instead of adding the nodes directly to the graph, they are added to
- * {@link #nodeAdditions}. {@link #generate(Graph)} adds these to the batch
+ * {@link #nodeAdditions}. {@link #generate(IGraph)} adds these to the batch
* to update the graph.
*
*
* @param event
* The {@link Old_Event} which nodes should be added.
*/
- private void addNodesForColumns(Graph g, Event event) {
+ private void addNodesForColumns(IGraph g, Event event) {
int globalMappingForEvent;
Node potentialNewNode;
for (EventColumn[] eventColumnGroup : this.columnGroupsToAddAsNodes) {
@@ -531,7 +531,7 @@ private void addNodesForColumns(Graph g, Event event) {
/**
* Adds the given {@link EdgeAddition} for given {@link Edge} to the updates
* to do in this batch. The {@link Edge} is then added by
- * {@link #generate(Graph)}.
+ * {@link #generate(IGraph)}.
*
* @param edge
* The {@link Edge} to add.
@@ -545,7 +545,7 @@ private void addToEdgeAdditionsForNewEdges(Edge edge, EdgeAddition update) {
/**
* Adds the given {@link EdgeWeight} for given {@link Edge} to the updates
* to do in this batch. The {@link Edge} is then updated by
- * {@link #generate(Graph)}.
+ * {@link #generate(IGraph)}.
*
* @param edge
* The {@link Edge} to update.
@@ -568,7 +568,7 @@ private void addToEdgeWeights(Edge edge, EdgeWeight update) {
/**
* Adds the given {@link NodeAddition} for given {@link Node} to the updates
* to do in this batch. The {@link Node} is then added by
- * {@link #generate(Graph)}.
+ * {@link #generate(IGraph)}.
*
* @param node
* The {@link Node} to add.
@@ -589,7 +589,7 @@ private void addToNodeAdditions(Node node, NodeAddition update) {
* this edge already, the weight of this edge is increased by given weight.
*
* Instead of adding the edge directly to the graph, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -601,7 +601,7 @@ private void addToNodeAdditions(Node node, NodeAddition update) {
* The weight of the edge to add or -if the edge already exists-
* the weight added to the current weight of the existing edge.
*/
- private void addUndirectedEdge(Graph g, Node source, Node target,
+ private void addUndirectedEdge(IGraph g, Node source, Node target,
double weight) {
final Edge edge = g.getGraphDatastructures().newEdgeInstance(source,
target);
@@ -641,7 +641,7 @@ private void addUndirectedEdge(Graph g, Node source, Node target,
* this edge already, the weight of this edge is increased by given weight.
*
* Instead of adding the edge directly to the graph, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -653,7 +653,7 @@ private void addUndirectedEdge(Graph g, Node source, Node target,
* The weight of the edge to add or -if the edge already exists-
* the weight added to the current weight of the existing edge.
*/
- private void addUndirectedEdge(Graph g, Node source, Node target, int weight) {
+ private void addUndirectedEdge(IGraph g, Node source, Node target, int weight) {
final Edge edge = g.getGraphDatastructures().newEdgeInstance(source,
target);
@@ -785,7 +785,7 @@ private int calculcateEdgeWeight(Edge edge, int weight) {
}
@Override
- public Batch generate(Graph g) {
+ public Batch generate(IGraph g) {
if (this.numberOfRuns == 0 && g.getNodeCount() > 0)
throw new IllegalArgumentException(
"To guarantee the correct meaning of the graph, it must be empty before the first generated batch and must only be modifidied by the same batch generator!");
@@ -851,11 +851,11 @@ public Map getTimestampsForGeneratedBatches() {
/**
* Note: returns always true! If no further batch is possible,
- * because there is no other event to read, {@link #generate(Graph)} returns
+ * because there is no other event to read, {@link #generate(IGraph)} returns
* an empty batch.
*/
@Override
- public boolean isFurtherBatchPossible(Graph g) {
+ public boolean isFurtherBatchPossible(IGraph g) {
return true;
}
diff --git a/src/dna/updates/generators/zalando/ZalandoChronologyBatchGenerator.java b/src/dna/updates/generators/zalando/ZalandoChronologyBatchGenerator.java
index 41588a7f..fa272c2d 100644
--- a/src/dna/updates/generators/zalando/ZalandoChronologyBatchGenerator.java
+++ b/src/dna/updates/generators/zalando/ZalandoChronologyBatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.zalando;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.edges.Edge;
@@ -94,7 +94,7 @@ public ZalandoChronologyBatchGenerator(String name,
*
*
* The edge is not added to the graph directly, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -105,7 +105,9 @@ public ZalandoChronologyBatchGenerator(String name,
* @see #addEdge(Node, Node, Object)
*/
@Override
- void addEdgesForColumns(Graph g, Event event) {
+ void addEdgesForColumns(IGraph g, Event event) {
+ // TODO
+// final GraphDataStructure gds = g.getGraphDatastructures();
int nodeForEventIndex, mappingForColumnGroup;
for (EventColumn[] eventColumnGroup : this.columnGroupsToAddAsNodes) {
nodeForEventIndex = this.mappings.getMapping(eventColumnGroup,
diff --git a/src/dna/updates/generators/zalando/ZalandoEqualityBatchGenerator.java b/src/dna/updates/generators/zalando/ZalandoEqualityBatchGenerator.java
index 72c25fb2..fa60a12a 100644
--- a/src/dna/updates/generators/zalando/ZalandoEqualityBatchGenerator.java
+++ b/src/dna/updates/generators/zalando/ZalandoEqualityBatchGenerator.java
@@ -1,6 +1,6 @@
package dna.updates.generators.zalando;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.datastructures.zalando.ZalandoGraphDataStructure;
import dna.graph.edges.Edge;
@@ -95,7 +95,7 @@ public ZalandoEqualityBatchGenerator(String name,
* source node, too.
*
* The edge is not added to the graph directly, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -109,7 +109,7 @@ public ZalandoEqualityBatchGenerator(String name,
*
* @see #addEdge(Node, Node, int)
*/
- void addBidirectionalEdge(Graph g, Node node1, Node node2, Object weight) {
+ void addBidirectionalEdge(IGraph g, Node node1, Node node2, Object weight) {
this.addEdge(g, node1, node2, weight);
if (g.isDirected())
@@ -128,7 +128,7 @@ void addBidirectionalEdge(Graph g, Node node1, Node node2, Object weight) {
*
*
* The edge is not added to the graph directly, it is added to
- * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(Graph)}
+ * {@link #edgeAdditions} or {@link #edgeWeights}. {@link #generate(IGraph)}
* adds these to the batch to update the graph.
*
*
@@ -139,7 +139,7 @@ void addBidirectionalEdge(Graph g, Node node1, Node node2, Object weight) {
* @see #addBidirectionalEdge(Node, Node, int)
*/
@Override
- void addEdgesForColumns(Graph g, Event event) {
+ void addEdgesForColumns(IGraph g, Event event) {
int nodeForEventIndex, mappingForColumnGroup;
for (EventColumn[] eventColumnGroup : this.columnGroupsToAddAsNodes) {
diff --git a/src/dna/updates/update/EdgeAddition.java b/src/dna/updates/update/EdgeAddition.java
index cff5e309..2316afc1 100644
--- a/src/dna/updates/update/EdgeAddition.java
+++ b/src/dna/updates/update/EdgeAddition.java
@@ -2,7 +2,7 @@
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.edges.IEdge;
@@ -15,13 +15,13 @@ public EdgeAddition(IEdge edge) {
super(edge);
}
- public EdgeAddition(String str, GraphDataStructure gds, Graph g,
+ public EdgeAddition(String str, GraphDataStructure gds, IGraph g,
HashMap addedNodes) {
super(gds.newEdgeInstance(str, g, addedNodes));
}
@Override
- public boolean apply_(Graph g) {
+ public boolean apply_(IGraph g) {
if (!g.addEdge((Edge) this.edge)) {
Log.error("could not add edge " + this.edge);
if (g.containsEdge((Edge) this.edge)) {
diff --git a/src/dna/updates/update/EdgeRemoval.java b/src/dna/updates/update/EdgeRemoval.java
index d7f2ae51..26b8cce5 100644
--- a/src/dna/updates/update/EdgeRemoval.java
+++ b/src/dna/updates/update/EdgeRemoval.java
@@ -1,6 +1,6 @@
package dna.updates.update;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.Edge;
@@ -14,19 +14,19 @@ public EdgeRemoval(IEdge edge) {
super(edge);
}
- public EdgeRemoval(String str, GraphDataStructure gds, Graph g) {
+ public EdgeRemoval(String str, GraphDataStructure gds, IGraph g) {
super(
g.getEdge(g.getNode(Integer.parseInt(str
.split(Update.EdgeSeparator)[0])), g.getNode(Integer
.parseInt(str.split(Update.EdgeSeparator)[1]))));
}
- public EdgeRemoval(int index1, int index2, GraphDataStructure gds, Graph g) {
+ public EdgeRemoval(int index1, int index2, GraphDataStructure gds, IGraph g) {
super(g.getEdge(g.getNode(index1), g.getNode(index2)));
}
@Override
- public boolean apply_(Graph g) {
+ public boolean apply_(IGraph g) {
boolean success = g.removeEdge((Edge) this.edge);
success &= this.edge.disconnectFromNodes();
return success;
diff --git a/src/dna/updates/update/EdgeWeight.java b/src/dna/updates/update/EdgeWeight.java
index 4a240a26..435cc08b 100644
--- a/src/dna/updates/update/EdgeWeight.java
+++ b/src/dna/updates/update/EdgeWeight.java
@@ -1,6 +1,6 @@
package dna.updates.update;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.IEdge;
@@ -22,7 +22,7 @@ public EdgeWeight(IWeightedEdge edge, Weight weight) {
this.weight = weight;
}
- public EdgeWeight(String str, GraphDataStructure gds, Graph g) {
+ public EdgeWeight(String str, GraphDataStructure gds, IGraph g) {
super(null);
String[] temp1 = str.split(Update.WeightDelimiter);
String[] temp2 = temp1[0].split(Update.EdgeSeparator);
@@ -33,7 +33,7 @@ public EdgeWeight(String str, GraphDataStructure gds, Graph g) {
}
@Override
- public boolean apply_(Graph g) {
+ public boolean apply_(IGraph g) {
((IWeightedEdge) this.edge).setWeight(this.weight);
return g.getEdge(this.edge.getN1(), this.edge.getN2()) == this.edge;
}
diff --git a/src/dna/updates/update/NodeAddition.java b/src/dna/updates/update/NodeAddition.java
index faa0721f..27191d33 100644
--- a/src/dna/updates/update/NodeAddition.java
+++ b/src/dna/updates/update/NodeAddition.java
@@ -1,6 +1,6 @@
package dna.updates.update;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.nodes.INode;
import dna.graph.nodes.Node;
@@ -16,7 +16,7 @@ public NodeAddition(String str, GraphDataStructure gds) {
}
@Override
- public boolean apply_(Graph g) {
+ public boolean apply_(IGraph g) {
return g.addNode((Node) this.node);
}
diff --git a/src/dna/updates/update/NodeRemoval.java b/src/dna/updates/update/NodeRemoval.java
index f86d900e..c3b0182b 100644
--- a/src/dna/updates/update/NodeRemoval.java
+++ b/src/dna/updates/update/NodeRemoval.java
@@ -1,6 +1,6 @@
package dna.updates.update;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.IElement;
import dna.graph.edges.DirectedEdge;
import dna.graph.edges.Edge;
@@ -17,12 +17,12 @@ public NodeRemoval(INode node) {
super(node);
}
- public NodeRemoval(String str, Graph g) {
+ public NodeRemoval(String str, IGraph g) {
super(g.getNode(Integer.parseInt(str)));
}
@Override
- public boolean apply_(Graph g) {
+ public boolean apply_(IGraph g) {
boolean success = true;
if (this.node instanceof DirectedNode) {
DirectedNode node = (DirectedNode) this.node;
diff --git a/src/dna/updates/update/NodeWeight.java b/src/dna/updates/update/NodeWeight.java
index a11eaa72..72f09b7b 100644
--- a/src/dna/updates/update/NodeWeight.java
+++ b/src/dna/updates/update/NodeWeight.java
@@ -1,6 +1,6 @@
package dna.updates.update;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.weights.IWeightedNode;
import dna.graph.weights.Weight;
@@ -17,7 +17,7 @@ public NodeWeight(IWeightedNode node, Weight weight) {
this.weight = weight;
}
- public NodeWeight(String str, Graph g) {
+ public NodeWeight(String str, IGraph g) {
super(null);
String[] temp = str.split(Update.WeightDelimiter);
this.node = g.getNode(Integer.parseInt(temp[0]));
@@ -25,7 +25,7 @@ public NodeWeight(String str, Graph g) {
}
@Override
- public boolean apply_(Graph g) {
+ public boolean apply_(IGraph g) {
((IWeightedNode) this.node).setWeight(this.weight);
return true;
}
diff --git a/src/dna/updates/update/Update.java b/src/dna/updates/update/Update.java
index f81e1ee3..6a3755dc 100644
--- a/src/dna/updates/update/Update.java
+++ b/src/dna/updates/update/Update.java
@@ -2,7 +2,7 @@
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.nodes.Node;
@@ -23,11 +23,11 @@ public static enum UpdateType {
// EDGE_WEIGHT
// };
- public boolean apply(Graph g) {
+ public boolean apply(IGraph g) {
return this.apply_(g);
}
- public abstract boolean apply_(Graph g);
+ public abstract boolean apply_(IGraph g);
public abstract UpdateType getType();
@@ -59,7 +59,7 @@ public boolean equals(Object o) {
return u.asString().equals(this.asString());
}
- public static Update fromString(GraphDataStructure gds, Graph g,
+ public static Update fromString(GraphDataStructure gds, IGraph g,
String str, HashMap addedNodes) {
String[] temp = str.split(Update.TypeDelimiter);
UpdateType t = UpdateType.valueOf(temp[0]);
diff --git a/src/dna/util/IOUtils.java b/src/dna/util/IOUtils.java
index 3fc351d8..6e728694 100644
--- a/src/dna/util/IOUtils.java
+++ b/src/dna/util/IOUtils.java
@@ -123,5 +123,97 @@ public static JarFile getExecutionJarFile() throws URISyntaxException,
return new JarFile(p.toFile(), false);
}
+
+ /**
+ * Removes root directory and the files and directories under the given
+ * path recursively. If the path represents a file the file will
+ * be deleted.
+ *
+ * @param path the root dir or the file
+ * @return true, if successful
+ */
+ public static boolean removeRecursive(String path) {
+ return IOUtils.removeRecursive(path, 0, 0, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Removes root directory and the files and directories under the given
+ * path recursively till the maximum depth. If the path represents a file
+ * the file will be deleted.
+ *
+ * @param path the root dir or the file
+ * @param maximumDepth the maximum depth
+ * @return true, if successful
+ * false, if the maximum depth was reached and there are still files
+ * or subdirectories
+ */
+ public static boolean removeRecursive(String path, int maximumDepth) {
+ return IOUtils.removeRecursive(path, 0, 0, maximumDepth);
+ }
+ /**
+ * Removes the files and directories under the given path recursively
+ * starting at startDepth till the endDepth is reached. If the path represents a file
+ * the file will be deleted.
+ *
+ * @param path the root dir or the file
+ * @param startDepth the start depth
+ * @param endDepth the end depth
+ * @return true, if successful
+ * false, if the end depth was reached and there are still files
+ * or subdirectories
+ */
+ public static boolean removeRecursive(String path, int startDepth, int endDepth) {
+ return IOUtils.removeRecursive(path, startDepth, 0, endDepth);
+ }
+
+ /**
+ * Removes the recursive.
+ *
+ * @param path the root dir
+ * @param startDepth the start depth
+ * @param currentDepth the current depth
+ * @param endDepth the end depth
+ * @return true, if successful
+ */
+ private static boolean removeRecursive(String path, int startDepth, int currentDepth, int endDepth) {
+ boolean result = true;
+ File root = new File(path);
+
+ if (!root.exists()) return false;
+
+ if (root.isDirectory()) {
+ for (File f: root.listFiles()) {
+ if (f.isFile() && startDepth <= currentDepth){
+ f.delete();
+ result = result && !f.exists();
+ if (!result) return false;
+ } else {
+ if (endDepth >= currentDepth) {
+ result = result && removeRecursive(f.getAbsolutePath(), startDepth, currentDepth + 1 , endDepth);
+ if (!result) return false;
+ }
+ }
+ }
+ }
+
+ if (startDepth <= currentDepth) {
+ root.delete();
+ result = result && !root.exists();
+ }
+
+ return result;
+ }
+
+ public static String getPathForOS(String path){
+ if (OsCheck.isWindows()) {
+ return path.replaceAll("((?= 0) || (OS.indexOf("darwin") >= 0)) {
+ detectedOS = OSType.MacOS;
+ } else if (OS.indexOf("win") >= 0) {
+ detectedOS = OSType.Windows;
+ } else if (OS.indexOf("nux") >= 0) {
+ detectedOS = OSType.Linux;
+ } else {
+ detectedOS = OSType.Other;
+ }
+ }
+ return detectedOS;
+ }
+
+ public static boolean isWindows() {
+ return getOperatingSystemType() == OSType.Windows;
+ }
+
+ public static boolean isLinux() {
+ return getOperatingSystemType() == OSType.Linux;
+ }
+
+ public static boolean isMacOS() {
+ return getOperatingSystemType() == OSType.MacOS;
+ }
+}
\ No newline at end of file
diff --git a/src/dna/util/TimerAspects.aj b/src/dna/util/TimerAspects.aj
index fb7eba4b..be4ecd93 100644
--- a/src/dna/util/TimerAspects.aj
+++ b/src/dna/util/TimerAspects.aj
@@ -2,7 +2,7 @@ package dna.util;
import java.util.HashMap;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.config.DSConfig;
import dna.graph.datastructures.hotswap.Hotswap;
import dna.graph.generators.GraphGenerator;
@@ -50,11 +50,11 @@ public aspect TimerAspects {
call(* IGraphGenerator+.generate(..))
);
- Graph around(GraphGenerator gg) : graphGeneration(gg) {
+ IGraph around(GraphGenerator gg) : graphGeneration(gg) {
// System.out.println("GENERATING graph " + gg.getName());
Timer t = new Timer(SeriesStats.graphGenerationRuntime);
- Graph res = proceed(gg);
+ IGraph res = proceed(gg);
t.end();
this.graphGeneration = t;
return res;
diff --git a/src/dna/visualization/graph/GraphVisualization.java b/src/dna/visualization/graph/GraphVisualization.java
index 0789c551..fd9e2a3f 100644
--- a/src/dna/visualization/graph/GraphVisualization.java
+++ b/src/dna/visualization/graph/GraphVisualization.java
@@ -10,7 +10,7 @@
import org.graphstream.graph.implementations.MultiGraph;
import org.graphstream.ui.layout.Layout;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
import dna.graph.weights.IWeightedEdge;
@@ -53,7 +53,7 @@ public class GraphVisualization {
Config.getInt("GRAPH_VIS_FRAME_HEIGHT"));
// graph map
- protected static HashMap map = new HashMap();
+ protected static HashMap map = new HashMap();
// current GraphPanel
protected static GraphPanel currentGraphPanel;
@@ -63,7 +63,7 @@ public class GraphVisualization {
* GRAPH
*/
/** Init graph g. **/
- public static void init(Graph g) {
+ public static void init(IGraph g) {
if (!init) {
// init sophisticated renderer
System.setProperty("org.graphstream.ui.renderer",
@@ -158,7 +158,7 @@ public static void init(Graph g) {
*/
/** Adds node n to graph g. **/
- public static void addNode(Graph g, Node n) {
+ public static void addNode(IGraph g, Node n) {
// wait some time
waitTime(Config.getInt("GRAPH_VIS_WAIT_NODE_ADDITION"));
@@ -167,7 +167,7 @@ public static void addNode(Graph g, Node n) {
}
/** Removes node n from graph g. **/
- public static void removeNode(Graph g, Node n) {
+ public static void removeNode(IGraph g, Node n) {
// wait some time
waitTime(Config.getInt("GRAPH_VIS_WAIT_NODE_REMOVAL"));
@@ -189,7 +189,7 @@ public static void changeNodeWeight(IWeightedNode n, Weight w) {
*/
/** Adds edge e to graph g. **/
- public static void addEdge(Graph g, Edge e) {
+ public static void addEdge(IGraph g, Edge e) {
// wait some time
waitTime(Config.getInt("GRAPH_VIS_WAIT_EDGE_ADDITION"));
@@ -198,7 +198,7 @@ public static void addEdge(Graph g, Edge e) {
}
/** Removes edge e from graph g. **/
- public static void removeEdge(Graph g, Edge e) {
+ public static void removeEdge(IGraph g, Edge e) {
// wait some time
waitTime(Config.getInt("GRAPH_VIS_WAIT_EDGE_REMOVAL"));
@@ -231,12 +231,12 @@ protected static void waitTime(long milliseconds) {
}
/** Sets the description text for the given graph. **/
- public static void setText(Graph g, String text) {
+ public static void setText(IGraph g, String text) {
map.get(g).setText(text);
}
/** Returns the GraphPanel belonging to graph g. **/
- public static GraphPanel getGraphPanel(Graph g) {
+ public static GraphPanel getGraphPanel(IGraph g) {
return GraphVisualization.map.get(g);
}
@@ -251,7 +251,7 @@ public static void setText(String text) {
}
/** Returns the layouter belonging to graph g. **/
- public static Layout getLayouter(Graph g) {
+ public static Layout getLayouter(IGraph g) {
return GraphVisualization.getGraphPanel(g).getLayouter();
}
@@ -266,7 +266,7 @@ public static Layout getLayouter() {
* Returned values will be between 0.0 and 1.0, where 0.0 is unstable and
* 1.0 means its completely stabilized and not moving.
**/
- public static double getStabilization(Graph g) {
+ public static double getStabilization(IGraph g) {
return GraphVisualization.getGraphPanel(g).getStabilization();
}
diff --git a/src/dna/visualization/graph/GraphVisualizationAspects.aj b/src/dna/visualization/graph/GraphVisualizationAspects.aj
index 33104c5a..68daef06 100644
--- a/src/dna/visualization/graph/GraphVisualizationAspects.aj
+++ b/src/dna/visualization/graph/GraphVisualizationAspects.aj
@@ -1,6 +1,6 @@
package dna.visualization.graph;
-import dna.graph.Graph;
+import dna.graph.IGraph;
import dna.graph.datastructures.GraphDataStructure;
import dna.graph.edges.Edge;
import dna.graph.nodes.Node;
@@ -18,8 +18,8 @@ public aspect GraphVisualizationAspects {
if(GraphVisualization.isEnabled()) &&
call(* GraphDataStructure.newGraphInstance(String, long, int, int));
- Graph around() : graphInit() {
- Graph g = proceed();
+ IGraph around() : graphInit() {
+ IGraph g = proceed();
GraphVisualization.init(g);
return g;
}
@@ -28,13 +28,13 @@ public aspect GraphVisualizationAspects {
* TIMESTAMP
*/
- pointcut graphTimestamp(Graph g, long newTimestamp) :
+ pointcut graphTimestamp(IGraph g, long newTimestamp) :
if(GraphVisualization.isEnabled()) &&
target(g) &&
args(newTimestamp) &&
- call(* Graph.setTimestamp(long));
+ call(* IGraph.setTimestamp(long));
- void around(Graph g, long newTimestamp) : graphTimestamp(g, newTimestamp) {
+ void around(IGraph g, long newTimestamp) : graphTimestamp(g, newTimestamp) {
long oldTimestamp = g.getTimestamp();
proceed(g, newTimestamp);
GraphVisualization.getGraphPanel(g).setTimestamp(newTimestamp);
@@ -44,23 +44,23 @@ public aspect GraphVisualizationAspects {
* NODE
*/
- pointcut nodeAddition(Graph g, Node n) :
+ pointcut nodeAddition(IGraph g, Node n) :
if(GraphVisualization.isEnabled()) &&
target(g) &&
args(n) &&
- call(* Graph.addNode(Node));
+ call(* IGraph.addNode(Node));
- after(Graph g, Node n) : nodeAddition(g, n) {
+ after(IGraph g, Node n) : nodeAddition(g, n) {
GraphVisualization.addNode(g, n);
}
- pointcut nodeRemoval(Graph g, Node n) :
+ pointcut nodeRemoval(IGraph g, Node n) :
if(GraphVisualization.isEnabled()) &&
target(g) &&
args(n) &&
- call(* Graph.removeNode(Node));
+ call(* IGraph.removeNode(Node));
- after(Graph g, Node n) : nodeRemoval(g, n) {
+ after(IGraph g, Node n) : nodeRemoval(g, n) {
GraphVisualization.removeNode(g, n);
}
@@ -78,23 +78,23 @@ public aspect GraphVisualizationAspects {
* EDGE
*/
- pointcut edgeAddition(Graph g, Edge e) :
+ pointcut edgeAddition(IGraph g, Edge e) :
if(GraphVisualization.isEnabled()) &&
target(g) &&
args(e) &&
- call(* Graph.addEdge(Edge));
+ call(* IGraph.addEdge(Edge));
- after(Graph g, Edge e) : edgeAddition(g, e) {
+ after(IGraph g, Edge e) : edgeAddition(g, e) {
GraphVisualization.addEdge(g, e);
}
- pointcut edgeRemoval(Graph g, Edge e) :
+ pointcut edgeRemoval(IGraph g, Edge e) :
if(GraphVisualization.isEnabled()) &&
target(g) &&
args(e) &&
- call(* Graph.removeEdge(Edge));
+ call(* IGraph.removeEdge(Edge));
- after(Graph g, Edge e) : edgeRemoval(g, e) {
+ after(IGraph g, Edge e) : edgeRemoval(g, e) {
GraphVisualization.removeEdge(g, e);
}