Skip to content

Commit

Permalink
Rename DGraph class
Browse files Browse the repository at this point in the history
  • Loading branch information
chdemko committed Jun 29, 2016
1 parent 3269dbe commit bd74e71
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 142 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.thegalactic.dgraph;

/*
* DGraph.java
* ConcreteDGraph.java
*
* Copyright: 2010-2015 Karell Bertet, France
* Copyright: 2015-2016 The Galactic Organization, France
Expand Down Expand Up @@ -33,17 +33,17 @@
* that associates to each node a treeset of successors, defined by class
* {@link Edge}; - a treemap of predecessors that associates to each node a
* treeset of predecessors, defined by class {@link Edge}.
*
* This class provides methods implementing classical operation on a directed
* graph:
*
* - sinks - wells - subgraph - reflexive closure and reduction - transitive
* closure - strongly connected components - ...
*
* This class also provides a static method randomly generating a directed
* graph.
*
* ![DGraph](DGraph.png)
This class provides methods implementing classical operation on a directed
graph:
- sinks - wells - subgraph - reflexive closure and reduction - transitive
closure - strongly connected components - ...
This class also provides a static method randomly generating a directed
graph.
![ConcreteDGraph](ConcreteDGraph.png)
*
* @uml DGraph.png
* !include resources/org/thegalactic/dgraph/DGraph.iuml
Expand All @@ -55,7 +55,7 @@
* class DGraph #LightCyan
* title DGraph UML graph
*/
public class DGraph extends AbstractDGraph implements Cloneable {
public class ConcreteDGraph extends AbstractDGraph implements Cloneable {

/*
* ------------- FIELDS ------------------
Expand All @@ -82,7 +82,7 @@ public class DGraph extends AbstractDGraph implements Cloneable {
/**
* Constructs a new directed graph with an empty set of node.
*/
public DGraph() {
public ConcreteDGraph() {
this.nodes = new TreeSet<Node>();
this.successors = new TreeMap<Node, SortedSet<Edge>>();
this.predecessors = new TreeMap<Node, SortedSet<Edge>>();
Expand All @@ -96,7 +96,7 @@ public DGraph() {
*
* @param set the set of nodes
*/
public DGraph(final Set<Node> set) {
public ConcreteDGraph(final Set<Node> set) {
this.nodes = new TreeSet<Node>(set);
this.successors = new TreeMap<Node, SortedSet<Edge>>();
for (Node node : this.nodes) {
Expand All @@ -113,7 +113,7 @@ public DGraph(final Set<Node> set) {
*
* @param graph the directed graph to be copied
*/
public DGraph(final DGraph graph) {
public ConcreteDGraph(final ConcreteDGraph graph) {
this.nodes = new TreeSet<Node>(graph.nodes);
this.successors = new TreeMap<Node, SortedSet<Edge>>();
this.predecessors = new TreeMap<Node, SortedSet<Edge>>();
Expand All @@ -135,8 +135,8 @@ public DGraph(final DGraph graph) {
* @throws java.lang.CloneNotSupportedException
*/
@Override
public DGraph clone() throws CloneNotSupportedException {
return new DGraph(this);
public ConcreteDGraph clone() throws CloneNotSupportedException {
return new ConcreteDGraph(this);
}

/**
Expand Down Expand Up @@ -588,8 +588,8 @@ public List<Node> topologicalSort() {
*
* @todo implement a SubGraph class?
*/
public DGraph getSubgraphByNodes(final Set<Node> nodes) {
DGraph graph = new DGraph();
public ConcreteDGraph getSubgraphByNodes(final Set<Node> nodes) {
ConcreteDGraph graph = new ConcreteDGraph();
// addition of nodes in the subgraph
for (Node node : nodes) {
if (this.containsNode(node)) {
Expand Down Expand Up @@ -618,8 +618,8 @@ public DGraph getSubgraphByNodes(final Set<Node> nodes) {
*
* @todo implement a SubGraph class?
*/
public DGraph getSubgraphByEdges(final Set<Edge> edges) {
DGraph graph = new DGraph();
public ConcreteDGraph getSubgraphByEdges(final Set<Edge> edges) {
ConcreteDGraph graph = new ConcreteDGraph();
// addition of all nodes in the subgraph
for (Node node : this.nodes) {
graph.addNode(node);
Expand Down Expand Up @@ -736,7 +736,7 @@ public int transitiveClosure() {
* its predecessor set, and its predecessor set by its successor set.
*/
public void transpose() {
DGraph tmp = new DGraph(this);
ConcreteDGraph tmp = new ConcreteDGraph(this);
for (Edge edge : tmp.getEdges()) {
this.removeEdge(edge);
this.addEdge(new Edge(edge.getTarget(), edge.getSource(), edge.getContent()));
Expand All @@ -756,11 +756,11 @@ public void transpose() {
public DAGraph getStronglyConnectedComponent() {
DAGraph cc = new DAGraph();
// first depth first search
DGraph tmp = new DGraph(this);
ConcreteDGraph tmp = new ConcreteDGraph(this);
tmp.transitiveClosure();
ArrayList<Node> last = tmp.depthFirstSearch()[1];
// transposition of the graph
DGraph transposedGraph = new DGraph(this);
ConcreteDGraph transposedGraph = new ConcreteDGraph(this);
transposedGraph.transpose();
// sort nodes according to the reverse last sort
ArrayList<Node> sort = new ArrayList<Node>();
Expand Down Expand Up @@ -802,7 +802,7 @@ public DAGraph getStronglyConnectedComponent() {
*
* @return this for chaining
*/
protected DGraph setNodes(final TreeSet<Node> nodes) {
protected ConcreteDGraph setNodes(final TreeSet<Node> nodes) {
this.nodes = nodes;
return this;
}
Expand All @@ -823,7 +823,7 @@ protected SortedMap<Node, SortedSet<Edge>> getSuccessors() {
*
* @return this for chaining
*/
protected DGraph setSuccessors(final TreeMap<Node, SortedSet<Edge>> successors) {
protected ConcreteDGraph setSuccessors(final TreeMap<Node, SortedSet<Edge>> successors) {
this.successors = successors;
return this;
}
Expand All @@ -844,7 +844,7 @@ protected SortedMap<Node, SortedSet<Edge>> getPredecessors() {
*
* @return this for chaining
*/
protected DGraph setPredecessors(final TreeMap<Node, SortedSet<Edge>> predecessors) {
protected ConcreteDGraph setPredecessors(final TreeMap<Node, SortedSet<Edge>> predecessors) {
this.predecessors = predecessors;
return this;
}
Expand Down Expand Up @@ -928,14 +928,14 @@ private class Edges extends AbstractSet<Edge> implements SortedSet<Edge> {
/**
* The underlying graph.
*/
private DGraph graph;
private ConcreteDGraph graph;

/**
* Get the underlying graph.
*
* @return the graph
*/
protected DGraph getGraph() {
protected ConcreteDGraph getGraph() {
return graph;
}

Expand Down Expand Up @@ -1022,9 +1022,9 @@ public boolean hasNext() {
/**
* Constructs a sorted set of the edges source a graph.
*
* @param graph A DGraph
* @param graph A ConcreteDGraph
*/
Edges(DGraph graph) {
Edges(ConcreteDGraph graph) {
this.graph = graph;
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/thegalactic/dgraph/DAGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
* This class extends the representation of a directed graph given by class
* {@link DGraph} for directed acyclic graph (DAG).
* {@link ConcreteDGraph} for directed acyclic graph (DAG).
*
* The main property of a directed acyclic graph is to be a partially ordered
* set (poset) when transitively closed, and a Hasse diagram when transitively
Expand Down Expand Up @@ -54,7 +54,7 @@
* class DAGraph #LightCyan
* title DAGraph UML graph
*/
public class DAGraph extends DGraph {
public class DAGraph extends ConcreteDGraph {

/*
* ----------- STATIC GENERATION METHODS -------------
Expand Down Expand Up @@ -152,9 +152,9 @@ public DAGraph(final Set<Node> set) {
* Acyclic property is checked for the specified DAG. When not verified,
* this component is construct with the same set of nodes but with no edges.
*
* @param graph the DGraph to be copied
* @param graph the ConcreteDGraph to be copied
*/
public DAGraph(final DGraph graph) {
public DAGraph(final ConcreteDGraph graph) {
super(graph);
if (this.isAcyclic()) {
this.reflexiveReduction();
Expand Down Expand Up @@ -262,9 +262,9 @@ public DAGraph ideal(final Node node) {
*/
@Override
public DAGraph getSubgraphByNodes(final Set<Node> nodes) {
DGraph tmp = new DGraph(this);
ConcreteDGraph tmp = new ConcreteDGraph(this);
tmp.transitiveClosure();
DGraph sub = tmp.getSubgraphByNodes(nodes);
ConcreteDGraph sub = tmp.getSubgraphByNodes(nodes);
DAGraph sub2 = new DAGraph(sub);
sub2.transitiveReduction();
return sub2;
Expand Down Expand Up @@ -346,7 +346,7 @@ public int transitiveReduction() {
* Computes the transitive closure of this component.
*
* This method overlaps the computation of the transitive closure for
* directed graph in class {@link DGraph} with an implementation of the
* directed graph in class {@link ConcreteDGraph} with an implementation of the
* Goralcikova-Koubeck algorithm dedicated to acyclic directed graph. This
* algorithm can also compute the transitive reduction of a directed acyclic
* graph.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/thegalactic/dgraph/DGraphFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public final class DGraphFactory {
*
* @return a random graph
*/
public DGraph random(final int size, final double threshold) {
final DGraph graph = new DGraph();
public ConcreteDGraph random(final int size, final double threshold) {
final ConcreteDGraph graph = new ConcreteDGraph();
// addition of nodes
for (int i = 1; i <= size; i++) {
final Node node = new Node(i);
Expand All @@ -56,7 +56,7 @@ public DGraph random(final int size, final double threshold) {
*
* @return a random graph
*/
public DGraph random(final int size) {
public ConcreteDGraph random(final int size) {
return this.random(size, 0.5);
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/thegalactic/dgraph/io/DGraphIOFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
* This file is part of java-lattices.
* You can redistribute it and/or modify it under the terms of the CeCILL-B license.
*/
import org.thegalactic.dgraph.DGraph;
import org.thegalactic.dgraph.ConcreteDGraph;

/**
* This class register readers and writers for the DGraph class.
*
* ![DGraphIOFactory](DGraphIOFactory.png)
* This class register readers and writers for the ConcreteDGraph class.
![DGraphIOFactory](DGraphIOFactory.png)
*
* @uml DGraphIOFactory.png
* !include resources/org/thegalactic/dgraph/io/DGraphIOFactory.iuml
Expand All @@ -26,7 +26,7 @@
* class DGraphIOFactory #LightCyan
* title DGraphIOFactory UML graph
*/
public final class DGraphIOFactory extends org.thegalactic.io.IOFactory<DGraph> {
public final class DGraphIOFactory extends org.thegalactic.io.IOFactory<ConcreteDGraph> {

/**
* The singleton instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.io.BufferedWriter;
import java.io.IOException;

import org.thegalactic.dgraph.DGraph;
import org.thegalactic.dgraph.ConcreteDGraph;
import org.thegalactic.dgraph.Edge;
import org.thegalactic.dgraph.Node;
import org.thegalactic.io.Writer;
Expand All @@ -34,7 +34,7 @@
* hide members show DGraphSerializerDot members class DGraphSerializerDot
* #LightCyan title DGraphSerializerDot UML graph
*/
public final class DGraphSerializerDot implements Writer<DGraph> {
public final class DGraphSerializerDot implements Writer<ConcreteDGraph> {

/**
* The singleton instance.
Expand Down Expand Up @@ -72,7 +72,7 @@ private DGraphSerializerDot() {
* @throws IOException When an IOException occurs
*/
@Override
public void write(final DGraph graph, final BufferedWriter file) throws IOException {
public void write(final ConcreteDGraph graph, final BufferedWriter file) throws IOException {
// Writing start of graph
file.write("digraph G {");
file.newLine();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/thegalactic/lattice/ArrowRelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.TreeSet;

import org.thegalactic.context.Context;
import org.thegalactic.dgraph.DGraph;
import org.thegalactic.dgraph.ConcreteDGraph;
import org.thegalactic.dgraph.Edge;
import org.thegalactic.dgraph.Node;
import org.thegalactic.io.Filer;
Expand Down Expand Up @@ -52,7 +52,7 @@
* class ArrowRelation #LightCyan
* title ArrowRelation UML graph
*/
public class ArrowRelation extends DGraph {
public class ArrowRelation extends ConcreteDGraph {

/**
* Field used to encode up arrow relation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.TreeSet;

import org.thegalactic.context.Context;
import org.thegalactic.dgraph.DGraph;
import org.thegalactic.dgraph.ConcreteDGraph;
import org.thegalactic.util.ComparableSet;

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ public class BijectiveComponents {
/**
* The dependency graph of the reduced lattice.
*/
private DGraph dependencyGraph = null;
private ConcreteDGraph dependencyGraph = null;

/**
* The minimal generators of the reduced lattice.
Expand Down Expand Up @@ -332,7 +332,7 @@ protected BijectiveComponents setReducedLattice(Lattice reducedLattice) {
*
* @return dependencyGraph dependency graph of this component
*/
public DGraph getDependencyGraph() {
public ConcreteDGraph getDependencyGraph() {
if (dependencyGraph == null) {
// FIXME: do we use getLattice or getReducedLattice ?
dependencyGraph = this.getReducedLattice().getDependencyGraph();
Expand All @@ -347,7 +347,7 @@ public DGraph getDependencyGraph() {
*
* @return this for chaining
*/
protected BijectiveComponents setDependencyGraph(DGraph dependencyGraph) {
protected BijectiveComponents setDependencyGraph(ConcreteDGraph dependencyGraph) {
this.dependencyGraph = dependencyGraph;
return this;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/thegalactic/lattice/ClosureSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Vector;

import org.thegalactic.dgraph.DAGraph;
import org.thegalactic.dgraph.DGraph;
import org.thegalactic.dgraph.ConcreteDGraph;
import org.thegalactic.dgraph.Node;
import org.thegalactic.util.ComparableSet;

Expand Down Expand Up @@ -208,7 +208,7 @@ public Concept nextClosure(Concept cl) {
*
* @return the precedence graph
*/
public DGraph precedenceGraph() {
public ConcreteDGraph precedenceGraph() {
// compute a TreeMap of closures for each element of the component
TreeMap<Comparable, TreeSet<Comparable>> closures = new TreeMap<Comparable, TreeSet<Comparable>>();
for (Comparable x : this.getSet()) {
Expand All @@ -217,7 +217,7 @@ public DGraph precedenceGraph() {
closures.put(x, this.closure(setX));
}
// nodes of the graph are elements
DGraph prec = new DGraph();
ConcreteDGraph prec = new ConcreteDGraph();
TreeMap<Comparable, Node> nodeCreated = new TreeMap<Comparable, Node>();
for (Comparable x : this.getSet()) {
Node node = new Node(x);
Expand Down Expand Up @@ -253,7 +253,7 @@ public TreeMap<Object, TreeSet> getReducibleElements() {
// Initialise a map Red of reducible attributes
TreeMap<Object, TreeSet> red = new TreeMap();
// Initialise the precedence graph G of the closure system
DGraph graph = this.precedenceGraph();
ConcreteDGraph graph = this.precedenceGraph();
// First, compute each group of equivalent attributes
// This group will be a strongly connected component on the graph.
// Then, only one element of each group is skipped, others will be deleted.
Expand Down
Loading

0 comments on commit bd74e71

Please sign in to comment.