You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2005/02/26 14:24:09 UTC
svn commit: r155447 [2/4] - in jakarta/commons/sandbox/graph2/trunk: ./
src/java/org/apache/commons/graph/
src/java/org/apache/commons/graph/algorithm/dataflow/
src/java/org/apache/commons/graph/algorithm/path/
src/java/org/apache/commons/graph/algorithm/search/
src/java/org/apache/commons/graph/algorithm/spanning/
src/java/org/apache/commons/graph/algorithm/util/
src/java/org/apache/commons/graph/contract/
src/java/org/apache/commons/graph/decorator/
src/java/org/apache/commons/graph/domain/basic/
src/java/org/apache/commons/graph/domain/dependency/
src/java/org/apache/commons/graph/domain/dependency/exception/
src/java/org/apache/commons/graph/domain/jdepend/
src/java/org/apache/commons/graph/domain/statemachine/
src/java/org/apache/commons/graph/domain/statemachine/exception/
src/java/org/apache/commons/graph/exception/
src/java/org/apache/commons/graph/factory/
src/java/org/apache/commons/graph/search/
src/java/org/apache/commons/graph/visualize/
src/test/org/apache/commons/graph/
src/test/org/apache/commons/graph/algorithm/dataflow/
src/test/org/apache/commons/graph/algorithm/path/
src/test/org/apache/commons/graph/algorithm/spanning/
src/test/org/apache/commons/graph/algorithm/util/
src/test/org/apache/commons/graph/contract/
src/test/org/apache/commons/graph/decorator/
src/test/org/apache/commons/graph/domain/dependency/ xdocs/
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/AcyclicContract.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/AcyclicContract.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/AcyclicContract.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/AcyclicContract.java Sat Feb 26 05:21:52 2005
@@ -1,5 +1,5 @@
-package org.apache.commons.graph.contract;
-
+package org.apache.commons.graph.contract;
+
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -14,154 +14,154 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-import java.util.Iterator;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.algorithm.search.*;
-import org.apache.commons.graph.exception.*;
-import org.apache.commons.graph.decorator.*;
-
-/**
- * Description of the Class
- */
-public class AcyclicContract
- implements Contract
-{
- private DDirectedGraph graph = null;
-
- /**
- * Description of the Class
- */
- public class CycleDetector
- implements Visitor
- {
- private DFS dfs = null;
- private boolean isCyclic = false;
- private DirectedGraph graph = null;
-
- /**
- * Constructor for the CycleDetector object
- *
- * @param graph
- */
- public CycleDetector(DirectedGraph graph)
- {
- this.dfs = new DFS();
- this.graph = graph;
- Iterator verts = graph.getVertices().iterator();
-
- if (verts.hasNext())
- {
- dfs.visit(graph, (Vertex) verts.next(), this);
- }
- }
-
- /**
- * Description of the Method
- */
- public void discoverGraph(Graph graph) { }
-
- /**
- * Description of the Method
- */
- public void discoverVertex(Vertex v) { }
-
- /**
- * Description of the Method
- */
- public void discoverEdge(Edge e)
- {
- if (dfs.getColor(graph.getTarget(e)) == DFS.GRAY)
- {
- this.isCyclic = true;
- }
- }
-
- /**
- * Description of the Method
- */
- public void finishEdge(Edge e) { }
-
- /**
- * Description of the Method
- */
- public void finishVertex(Vertex v) { }
-
- /**
- * Description of the Method
- */
- public void finishGraph(Graph graph) { }
-
- /**
- * Description of the Method
- */
- public boolean hasCycle()
- {
- return isCyclic;
- }
- }
-
- /**
- * Constructor for the AcyclicContract object
- */
- public AcyclicContract() { }
-
- /**
- * Sets the impl attribute of the AcyclicContract object
- */
- public void setImpl(DirectedGraph graph)
- {
- this.graph = DDirectedGraph.decorateGraph(graph);
- }
-
- /**
- * Gets the interface attribute of the AcyclicContract object
- */
- public Class getInterface()
- {
- return org.apache.commons.graph.contract.Acyclic.class;
- }
-
- /**
- * Description of the Method
- */
- public void verify()
- throws CycleException
- {
- CycleDetector cd = new CycleDetector(graph);
- if (cd.hasCycle())
- {
- throw new CycleException("Cycle detected in Graph.");
- }
- }
-
- /**
- * Adds a feature to the Vertex attribute of the AcyclicContract object
- */
- public void addVertex(Vertex v) { }
-
- /**
- * Adds a feature to the Edge attribute of the AcyclicContract object
- */
- public void addEdge(Edge e,
- Vertex start,
- Vertex end)
- throws GraphException
- {
- if (graph.hasConnection(end, start))
- {
- throw new CycleException("Introducing edge will cause a Cycle.");
- }
- }
-
- /**
- * Description of the Method
- */
- public void removeVertex(Vertex v) { }
-
- /**
- * Description of the Method
- */
- public void removeEdge(Edge e) { }
-}
+ */
+import java.util.Iterator;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.algorithm.search.*;
+import org.apache.commons.graph.exception.*;
+import org.apache.commons.graph.decorator.*;
+
+/**
+ * Description of the Class
+ */
+public class AcyclicContract
+ implements Contract
+{
+ private DDirectedGraph graph = null;
+
+ /**
+ * Description of the Class
+ */
+ public class CycleDetector
+ implements Visitor
+ {
+ private DFS dfs = null;
+ private boolean isCyclic = false;
+ private DirectedGraph graph = null;
+
+ /**
+ * Constructor for the CycleDetector object
+ *
+ * @param graph
+ */
+ public CycleDetector(DirectedGraph graph)
+ {
+ this.dfs = new DFS();
+ this.graph = graph;
+ Iterator verts = graph.getVertices().iterator();
+
+ if (verts.hasNext())
+ {
+ dfs.visit(graph, (Vertex) verts.next(), this);
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void discoverGraph(Graph graph) { }
+
+ /**
+ * Description of the Method
+ */
+ public void discoverVertex(Vertex v) { }
+
+ /**
+ * Description of the Method
+ */
+ public void discoverEdge(Edge e)
+ {
+ if (dfs.getColor(graph.getTarget(e)) == DFS.GRAY)
+ {
+ this.isCyclic = true;
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void finishEdge(Edge e) { }
+
+ /**
+ * Description of the Method
+ */
+ public void finishVertex(Vertex v) { }
+
+ /**
+ * Description of the Method
+ */
+ public void finishGraph(Graph graph) { }
+
+ /**
+ * Description of the Method
+ */
+ public boolean hasCycle()
+ {
+ return isCyclic;
+ }
+ }
+
+ /**
+ * Constructor for the AcyclicContract object
+ */
+ public AcyclicContract() { }
+
+ /**
+ * Sets the impl attribute of the AcyclicContract object
+ */
+ public void setImpl(DirectedGraph graph)
+ {
+ this.graph = DDirectedGraph.decorateGraph(graph);
+ }
+
+ /**
+ * Gets the interface attribute of the AcyclicContract object
+ */
+ public Class getInterface()
+ {
+ return org.apache.commons.graph.contract.Acyclic.class;
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void verify()
+ throws CycleException
+ {
+ CycleDetector cd = new CycleDetector(graph);
+ if (cd.hasCycle())
+ {
+ throw new CycleException("Cycle detected in Graph.");
+ }
+ }
+
+ /**
+ * Adds a feature to the Vertex attribute of the AcyclicContract object
+ */
+ public void addVertex(Vertex v) { }
+
+ /**
+ * Adds a feature to the Edge attribute of the AcyclicContract object
+ */
+ public void addEdge(Edge e,
+ Vertex start,
+ Vertex end)
+ throws GraphException
+ {
+ if (graph.hasConnection(end, start))
+ {
+ throw new CycleException("Introducing edge will cause a Cycle.");
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void removeVertex(Vertex v) { }
+
+ /**
+ * Description of the Method
+ */
+ public void removeEdge(Edge e) { }
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/AcyclicContract.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/Contract.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/Contract.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/Contract.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/Contract.java Sat Feb 26 05:21:52 2005
@@ -1,57 +1,57 @@
-package org.apache.commons.graph.contract;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.exception.*;
-
-/**
- * Description of the Interface
- */
-public interface Contract
-{
- /**
- * The impl that gets passed in is read-only. This is the representation of
- * the graph you should work off of. If an edge or vertex addition is
- * illegal to the contract, raise a GraphException with and explanation.
- */
- public void setImpl(DirectedGraph impl);
-
- /**
- * getInterface This returns the marker interface which is associated with
- * the Contract. For instance, AcyclicContract will return AcyclicGraph
- * here.
- */
- public Class getInterface();
-
- /**
- * verify - This verifies that the graph it is working on complies.
- */
- public void verify()
- throws GraphException;
-
- /**
- * Adds a feature to the Edge attribute of the Contract object
- */
- public void addEdge(Edge e,
- Vertex start,
- Vertex end)
- throws GraphException;
-
- /**
- * Adds a feature to the Vertex attribute of the Contract object
- */
- public void addVertex(Vertex v)
- throws GraphException;
-
- /**
- * Description of the Method
- */
- public void removeEdge(Edge e)
- throws GraphException;
-
- /**
- * Description of the Method
- */
- public void removeVertex(Vertex v)
- throws GraphException;
-
-}
+package org.apache.commons.graph.contract;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.exception.*;
+
+/**
+ * Description of the Interface
+ */
+public interface Contract
+{
+ /**
+ * The impl that gets passed in is read-only. This is the representation of
+ * the graph you should work off of. If an edge or vertex addition is
+ * illegal to the contract, raise a GraphException with and explanation.
+ */
+ public void setImpl(DirectedGraph impl);
+
+ /**
+ * getInterface This returns the marker interface which is associated with
+ * the Contract. For instance, AcyclicContract will return AcyclicGraph
+ * here.
+ */
+ public Class getInterface();
+
+ /**
+ * verify - This verifies that the graph it is working on complies.
+ */
+ public void verify()
+ throws GraphException;
+
+ /**
+ * Adds a feature to the Edge attribute of the Contract object
+ */
+ public void addEdge(Edge e,
+ Vertex start,
+ Vertex end)
+ throws GraphException;
+
+ /**
+ * Adds a feature to the Vertex attribute of the Contract object
+ */
+ public void addVertex(Vertex v)
+ throws GraphException;
+
+ /**
+ * Description of the Method
+ */
+ public void removeEdge(Edge e)
+ throws GraphException;
+
+ /**
+ * Description of the Method
+ */
+ public void removeVertex(Vertex v)
+ throws GraphException;
+
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/contract/Contract.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/decorator/DDirectedGraph.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java Sat Feb 26 05:21:52 2005
@@ -1,5 +1,5 @@
-package org.apache.commons.graph.domain.basic;
-
+package org.apache.commons.graph.domain.basic;
+
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -14,410 +14,410 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-import java.lang.reflect.*;
-
-import java.util.Set;
-import java.util.Map;
-import java.util.List;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ArrayList;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.contract.*;
-import org.apache.commons.graph.exception.*;
-
-/**
- * Description of the Class
- */
-public class DirectedGraphImpl
- implements DirectedGraph,
- WeightedGraph,
- MutableDirectedGraph,
- InvocationHandler
-{
- private Vertex root = null;
-
- private Set vertices = new HashSet();
- private Set edges = new HashSet();
- private List contracts = new ArrayList();
-
- private Map inbound = new HashMap();// VERTEX X SET( EDGE )
- private Map outbound = new HashMap();// - " " -
-
- private Map edgeSource = new HashMap();// EDGE X VERTEX
- private Map edgeTarget = new HashMap();// EDGE X TARGET
-
- private Map edgeWeights = new HashMap();// EDGE X WEIGHT
-
- /**
- * Constructor for the DirectedGraphImpl object
- */
- public DirectedGraphImpl() { }
-
- /**
- * Constructor for the DirectedGraphImpl object
- *
- * @param dg
- */
- public DirectedGraphImpl(DirectedGraph dg)
- {
-
- Iterator v = dg.getVertices().iterator();
- while (v.hasNext())
- {
- addVertexI((Vertex) v.next());
- }
-
- Iterator e = dg.getEdges().iterator();
- while (e.hasNext())
- {
- Edge edge = (Edge) e.next();
- addEdgeI(edge,
- dg.getSource(edge),
- dg.getTarget(edge));
-
- if (dg instanceof WeightedGraph)
- {
- setWeight(edge, ((WeightedGraph) dg).getWeight(edge));
- }
- }
- }
-
- /**
- * Adds a feature to the Contract attribute of the DirectedGraphImpl object
- */
- public void addContract(Contract c)
- throws GraphException
- {
- c.setImpl(this);
- c.verify();
- contracts.add(c);
- }
-
- /**
- * Description of the Method
- */
- public void removeContract(Contract c)
- {
- contracts.remove(c);
- }
-
- /**
- * Sets the weight attribute of the DirectedGraphImpl object
- */
- public void setWeight(Edge e, double value)
- {
- if (edgeWeights.containsKey(e))
- {
- edgeWeights.remove(e);
- }
- edgeWeights.put(e, new Double(value));
- }
-
- // Interface Methods
- // Graph
- /**
- * Gets the vertices attribute of the DirectedGraphImpl object
- */
- public Set getVertices()
- {
- return new HashSet(vertices);
- }
-
- /**
- * Gets the vertices attribute of the DirectedGraphImpl object
- */
- public Set getVertices(Edge e)
- {
- Set RC = new HashSet();
- if (edgeSource.containsKey(e))
- {
- RC.add(edgeSource.get(e));
- }
-
- if (edgeTarget.containsKey(e))
- {
- RC.add(edgeTarget.get(e));
- }
-
- return RC;
- }
-
- /**
- * Gets the edges attribute of the DirectedGraphImpl object
- */
- public Set getEdges()
- {
- return new HashSet(edges);
- }
-
- /**
- * Gets the edges attribute of the DirectedGraphImpl object
- */
- public Set getEdges(Vertex v)
- {
- Set RC = new HashSet();
- if (inbound.containsKey(v))
- {
- RC.addAll((Set) inbound.get(v));
- }
-
- if (outbound.containsKey(v))
- {
- RC.addAll((Set) outbound.get(v));
- }
-
- return RC;
- }
-
- // Directed Graph
- /**
- * Gets the source attribute of the DirectedGraphImpl object
- */
- public Vertex getSource(Edge e)
- {
- return (Vertex) edgeSource.get(e);
- }
-
- /**
- * Gets the target attribute of the DirectedGraphImpl object
- */
- public Vertex getTarget(Edge e)
- {
- return (Vertex) edgeTarget.get(e);
- }
-
- /**
- * Gets the inbound attribute of the DirectedGraphImpl object
- */
- public Set getInbound(Vertex v)
- {
- if (inbound.containsKey(v))
- {
- return new HashSet((Set) inbound.get(v));
- }
- else
- {
- return new HashSet();
- }
- }
-
- /**
- * Gets the outbound attribute of the DirectedGraphImpl object
- */
- public Set getOutbound(Vertex v)
- {
- if (outbound.containsKey(v))
- {
- return new HashSet((Set) outbound.get(v));
- }
- else
- {
- return new HashSet();
- }
- }
-
-
- // MutableDirectedGraph
- /**
- * Adds a feature to the VertexI attribute of the DirectedGraphImpl object
- */
- private void addVertexI(Vertex v)
- throws GraphException
- {
- if (root == null) root = v;
-
- vertices.add(v);
- }
-
- /**
- * Adds a feature to the Vertex attribute of the DirectedGraphImpl object
- */
- public void addVertex(Vertex v)
- throws GraphException
- {
- Iterator conts = contracts.iterator();
- while (conts.hasNext())
- {
- ((Contract) conts.next()).addVertex(v);
- }
- addVertexI(v);
- }
-
- /**
- * Description of the Method
- */
- private void removeVertexI(Vertex v)
- throws GraphException
- {
- try
- {
- vertices.remove(v);
- }
- catch (Exception ex)
- {
- throw new GraphException(ex);
- }
- }
-
- /**
- * Description of the Method
- */
- public void removeVertex(Vertex v)
- throws GraphException
- {
- Iterator conts = contracts.iterator();
- while (conts.hasNext())
- {
- ((Contract) conts.next()).removeVertex(v);
- }
-
- removeVertexI(v);
- }
-
-
- /**
- * Adds a feature to the EdgeI attribute of the DirectedGraphImpl object
- */
- private void addEdgeI(Edge e, Vertex start, Vertex end)
- throws GraphException
- {
- edges.add(e);
-
- if (e instanceof WeightedEdge)
- {
- edgeWeights.put(e, new Double(((WeightedEdge) e).getWeight()));
- }
- else
- {
- edgeWeights.put(e, new Double(1.0));
- }
-
- edgeSource.put(e, start);
- edgeTarget.put(e, end);
-
- if (!outbound.containsKey(start))
- {
- Set edgeSet = new HashSet();
- edgeSet.add(e);
-
- outbound.put(start, edgeSet);
- }
- else
- {
- ((Set) outbound.get(start)).add(e);
- }
-
- if (!inbound.containsKey(end))
- {
- Set edgeSet = new HashSet();
- edgeSet.add(e);
-
- inbound.put(end, edgeSet);
- }
- else
- {
- ((Set) inbound.get(end)).add(e);
- }
- }
-
- /**
- * Adds a feature to the Edge attribute of the DirectedGraphImpl object
- */
- public void addEdge(Edge e,
- Vertex start,
- Vertex end)
- throws GraphException
- {
- Iterator conts = contracts.iterator();
- while (conts.hasNext())
- {
- Contract cont = (Contract) conts.next();
-
- cont.addEdge(e, start, end);
- }
-
- addEdgeI(e, start, end);
- }
-
-
- /**
- * Description of the Method
- */
- private void removeEdgeI(Edge e)
- throws GraphException
- {
- try
- {
- Set edgeSet = null;
-
- Vertex source = (Vertex) edgeSource.get(e);
- edgeSource.remove(e);
- edgeSet = (Set) outbound.get(source);
- edgeSet.remove(e);
-
- Vertex target = (Vertex) edgeTarget.get(e);
- edgeTarget.remove(e);
- edgeSet = (Set) inbound.get(target);
- edgeSet.remove(e);
-
- if (edgeWeights.containsKey(e))
- {
- edgeWeights.remove(e);
- }
- }
- catch (Exception ex)
- {
- throw new GraphException(ex);
- }
- }
-
- /**
- * Description of the Method
- */
- public void removeEdge(Edge e)
- throws GraphException
- {
- Iterator conts = contracts.iterator();
- while (conts.hasNext())
- {
- ((Contract) conts.next()).removeEdge(e);
- }
- removeEdgeI(e);
- }
-
- // WeightedGraph
- /**
- * Gets the weight attribute of the DirectedGraphImpl object
- */
- public double getWeight(Edge e)
- {
- if (edgeWeights.containsKey(e))
- {
- return ((Double) edgeWeights.get(e)).doubleValue();
- }
- else
- {
- return 1.0;
- }
- }
-
- /**
- * Description of the Method
- */
- public Object invoke(Object proxy,
- Method method,
- Object args[])
- throws Throwable
- {
- try {
- return method.invoke(this, args);
- } catch (InvocationTargetException ex) {
- throw ex.getTargetException();
- }
- }
-
-}
+ */
+import java.lang.reflect.*;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.contract.*;
+import org.apache.commons.graph.exception.*;
+
+/**
+ * Description of the Class
+ */
+public class DirectedGraphImpl
+ implements DirectedGraph,
+ WeightedGraph,
+ MutableDirectedGraph,
+ InvocationHandler
+{
+ private Vertex root = null;
+
+ private Set vertices = new HashSet();
+ private Set edges = new HashSet();
+ private List contracts = new ArrayList();
+
+ private Map inbound = new HashMap();// VERTEX X SET( EDGE )
+ private Map outbound = new HashMap();// - " " -
+
+ private Map edgeSource = new HashMap();// EDGE X VERTEX
+ private Map edgeTarget = new HashMap();// EDGE X TARGET
+
+ private Map edgeWeights = new HashMap();// EDGE X WEIGHT
+
+ /**
+ * Constructor for the DirectedGraphImpl object
+ */
+ public DirectedGraphImpl() { }
+
+ /**
+ * Constructor for the DirectedGraphImpl object
+ *
+ * @param dg
+ */
+ public DirectedGraphImpl(DirectedGraph dg)
+ {
+
+ Iterator v = dg.getVertices().iterator();
+ while (v.hasNext())
+ {
+ addVertexI((Vertex) v.next());
+ }
+
+ Iterator e = dg.getEdges().iterator();
+ while (e.hasNext())
+ {
+ Edge edge = (Edge) e.next();
+ addEdgeI(edge,
+ dg.getSource(edge),
+ dg.getTarget(edge));
+
+ if (dg instanceof WeightedGraph)
+ {
+ setWeight(edge, ((WeightedGraph) dg).getWeight(edge));
+ }
+ }
+ }
+
+ /**
+ * Adds a feature to the Contract attribute of the DirectedGraphImpl object
+ */
+ public void addContract(Contract c)
+ throws GraphException
+ {
+ c.setImpl(this);
+ c.verify();
+ contracts.add(c);
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void removeContract(Contract c)
+ {
+ contracts.remove(c);
+ }
+
+ /**
+ * Sets the weight attribute of the DirectedGraphImpl object
+ */
+ public void setWeight(Edge e, double value)
+ {
+ if (edgeWeights.containsKey(e))
+ {
+ edgeWeights.remove(e);
+ }
+ edgeWeights.put(e, new Double(value));
+ }
+
+ // Interface Methods
+ // Graph
+ /**
+ * Gets the vertices attribute of the DirectedGraphImpl object
+ */
+ public Set getVertices()
+ {
+ return new HashSet(vertices);
+ }
+
+ /**
+ * Gets the vertices attribute of the DirectedGraphImpl object
+ */
+ public Set getVertices(Edge e)
+ {
+ Set RC = new HashSet();
+ if (edgeSource.containsKey(e))
+ {
+ RC.add(edgeSource.get(e));
+ }
+
+ if (edgeTarget.containsKey(e))
+ {
+ RC.add(edgeTarget.get(e));
+ }
+
+ return RC;
+ }
+
+ /**
+ * Gets the edges attribute of the DirectedGraphImpl object
+ */
+ public Set getEdges()
+ {
+ return new HashSet(edges);
+ }
+
+ /**
+ * Gets the edges attribute of the DirectedGraphImpl object
+ */
+ public Set getEdges(Vertex v)
+ {
+ Set RC = new HashSet();
+ if (inbound.containsKey(v))
+ {
+ RC.addAll((Set) inbound.get(v));
+ }
+
+ if (outbound.containsKey(v))
+ {
+ RC.addAll((Set) outbound.get(v));
+ }
+
+ return RC;
+ }
+
+ // Directed Graph
+ /**
+ * Gets the source attribute of the DirectedGraphImpl object
+ */
+ public Vertex getSource(Edge e)
+ {
+ return (Vertex) edgeSource.get(e);
+ }
+
+ /**
+ * Gets the target attribute of the DirectedGraphImpl object
+ */
+ public Vertex getTarget(Edge e)
+ {
+ return (Vertex) edgeTarget.get(e);
+ }
+
+ /**
+ * Gets the inbound attribute of the DirectedGraphImpl object
+ */
+ public Set getInbound(Vertex v)
+ {
+ if (inbound.containsKey(v))
+ {
+ return new HashSet((Set) inbound.get(v));
+ }
+ else
+ {
+ return new HashSet();
+ }
+ }
+
+ /**
+ * Gets the outbound attribute of the DirectedGraphImpl object
+ */
+ public Set getOutbound(Vertex v)
+ {
+ if (outbound.containsKey(v))
+ {
+ return new HashSet((Set) outbound.get(v));
+ }
+ else
+ {
+ return new HashSet();
+ }
+ }
+
+
+ // MutableDirectedGraph
+ /**
+ * Adds a feature to the VertexI attribute of the DirectedGraphImpl object
+ */
+ private void addVertexI(Vertex v)
+ throws GraphException
+ {
+ if (root == null) root = v;
+
+ vertices.add(v);
+ }
+
+ /**
+ * Adds a feature to the Vertex attribute of the DirectedGraphImpl object
+ */
+ public void addVertex(Vertex v)
+ throws GraphException
+ {
+ Iterator conts = contracts.iterator();
+ while (conts.hasNext())
+ {
+ ((Contract) conts.next()).addVertex(v);
+ }
+ addVertexI(v);
+ }
+
+ /**
+ * Description of the Method
+ */
+ private void removeVertexI(Vertex v)
+ throws GraphException
+ {
+ try
+ {
+ vertices.remove(v);
+ }
+ catch (Exception ex)
+ {
+ throw new GraphException(ex);
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void removeVertex(Vertex v)
+ throws GraphException
+ {
+ Iterator conts = contracts.iterator();
+ while (conts.hasNext())
+ {
+ ((Contract) conts.next()).removeVertex(v);
+ }
+
+ removeVertexI(v);
+ }
+
+
+ /**
+ * Adds a feature to the EdgeI attribute of the DirectedGraphImpl object
+ */
+ private void addEdgeI(Edge e, Vertex start, Vertex end)
+ throws GraphException
+ {
+ edges.add(e);
+
+ if (e instanceof WeightedEdge)
+ {
+ edgeWeights.put(e, new Double(((WeightedEdge) e).getWeight()));
+ }
+ else
+ {
+ edgeWeights.put(e, new Double(1.0));
+ }
+
+ edgeSource.put(e, start);
+ edgeTarget.put(e, end);
+
+ if (!outbound.containsKey(start))
+ {
+ Set edgeSet = new HashSet();
+ edgeSet.add(e);
+
+ outbound.put(start, edgeSet);
+ }
+ else
+ {
+ ((Set) outbound.get(start)).add(e);
+ }
+
+ if (!inbound.containsKey(end))
+ {
+ Set edgeSet = new HashSet();
+ edgeSet.add(e);
+
+ inbound.put(end, edgeSet);
+ }
+ else
+ {
+ ((Set) inbound.get(end)).add(e);
+ }
+ }
+
+ /**
+ * Adds a feature to the Edge attribute of the DirectedGraphImpl object
+ */
+ public void addEdge(Edge e,
+ Vertex start,
+ Vertex end)
+ throws GraphException
+ {
+ Iterator conts = contracts.iterator();
+ while (conts.hasNext())
+ {
+ Contract cont = (Contract) conts.next();
+
+ cont.addEdge(e, start, end);
+ }
+
+ addEdgeI(e, start, end);
+ }
+
+
+ /**
+ * Description of the Method
+ */
+ private void removeEdgeI(Edge e)
+ throws GraphException
+ {
+ try
+ {
+ Set edgeSet = null;
+
+ Vertex source = (Vertex) edgeSource.get(e);
+ edgeSource.remove(e);
+ edgeSet = (Set) outbound.get(source);
+ edgeSet.remove(e);
+
+ Vertex target = (Vertex) edgeTarget.get(e);
+ edgeTarget.remove(e);
+ edgeSet = (Set) inbound.get(target);
+ edgeSet.remove(e);
+
+ if (edgeWeights.containsKey(e))
+ {
+ edgeWeights.remove(e);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new GraphException(ex);
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void removeEdge(Edge e)
+ throws GraphException
+ {
+ Iterator conts = contracts.iterator();
+ while (conts.hasNext())
+ {
+ ((Contract) conts.next()).removeEdge(e);
+ }
+ removeEdgeI(e);
+ }
+
+ // WeightedGraph
+ /**
+ * Gets the weight attribute of the DirectedGraphImpl object
+ */
+ public double getWeight(Edge e)
+ {
+ if (edgeWeights.containsKey(e))
+ {
+ return ((Double) edgeWeights.get(e)).doubleValue();
+ }
+ else
+ {
+ return 1.0;
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public Object invoke(Object proxy,
+ Method method,
+ Object args[])
+ throws Throwable
+ {
+ try {
+ return method.invoke(this, args);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphWrapper.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphWrapper.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphWrapper.java Sat Feb 26 05:21:52 2005
@@ -1,5 +1,5 @@
-package org.apache.commons.graph.domain.basic;
-
+package org.apache.commons.graph.domain.basic;
+
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -14,91 +14,91 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-/**
- * DirectedGraphWrapper This is a superclass to all wrappers that work over
- * DirectedGraphs.
- */
-
-import java.util.Set;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class DirectedGraphWrapper
- extends GraphWrapper
- implements DirectedGraph
-{
- private DirectedGraph impl = null;
-
- /**
- * Constructor for the DirectedGraphWrapper object
- *
- * @param graph
- */
- public DirectedGraphWrapper(DirectedGraph graph)
- {
- super(graph);
- impl = graph;
- }
-
- /**
- * Constructor for the DirectedGraphWrapper object
- */
- public DirectedGraphWrapper()
- {
- super();
- }
-
- /**
- * Sets the dirGraph attribute of the DirectedGraphWrapper object
- */
- public void setDirGraph(DirectedGraph graph)
- {
- impl = graph;
- setGraph(graph);
- }
-
- /**
- * Gets the inbound attribute of the DirectedGraphWrapper object
- */
- public Set getInbound(Vertex v)
- {
- return impl.getInbound(v);
- }
-
- /**
- * Gets the outbound attribute of the DirectedGraphWrapper object
- */
- public Set getOutbound(Vertex v)
- {
- return impl.getOutbound(v);
- }
-
- /**
- * Gets the source attribute of the DirectedGraphWrapper object
- */
- public Vertex getSource(Edge e)
- {
- return impl.getSource(e);
- }
-
- /**
- * Gets the target attribute of the DirectedGraphWrapper object
- */
- public Vertex getTarget(Edge e)
- {
- return impl.getTarget(e);
- }
-
-}
-
-
-
-
-
-
-
+ */
+
+/**
+ * DirectedGraphWrapper This is a superclass to all wrappers that work over
+ * DirectedGraphs.
+ */
+
+import java.util.Set;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class DirectedGraphWrapper
+ extends GraphWrapper
+ implements DirectedGraph
+{
+ private DirectedGraph impl = null;
+
+ /**
+ * Constructor for the DirectedGraphWrapper object
+ *
+ * @param graph
+ */
+ public DirectedGraphWrapper(DirectedGraph graph)
+ {
+ super(graph);
+ impl = graph;
+ }
+
+ /**
+ * Constructor for the DirectedGraphWrapper object
+ */
+ public DirectedGraphWrapper()
+ {
+ super();
+ }
+
+ /**
+ * Sets the dirGraph attribute of the DirectedGraphWrapper object
+ */
+ public void setDirGraph(DirectedGraph graph)
+ {
+ impl = graph;
+ setGraph(graph);
+ }
+
+ /**
+ * Gets the inbound attribute of the DirectedGraphWrapper object
+ */
+ public Set getInbound(Vertex v)
+ {
+ return impl.getInbound(v);
+ }
+
+ /**
+ * Gets the outbound attribute of the DirectedGraphWrapper object
+ */
+ public Set getOutbound(Vertex v)
+ {
+ return impl.getOutbound(v);
+ }
+
+ /**
+ * Gets the source attribute of the DirectedGraphWrapper object
+ */
+ public Vertex getSource(Edge e)
+ {
+ return impl.getSource(e);
+ }
+
+ /**
+ * Gets the target attribute of the DirectedGraphWrapper object
+ */
+ public Vertex getTarget(Edge e)
+ {
+ return impl.getTarget(e);
+ }
+
+}
+
+
+
+
+
+
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/DirectedGraphWrapper.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/GraphWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/GraphWrapper.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/GraphWrapper.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/GraphWrapper.java Sat Feb 26 05:21:52 2005
@@ -1,74 +1,74 @@
-package org.apache.commons.graph.domain.basic;
-
-/**
- * GraphWrapper This is a superclass of all Wrapper implementations. It
- * basically does a redirection to the graph.
- */
-
-import java.util.Set;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class GraphWrapper
-{
- private Graph impl = null;
-
- /**
- * Constructor for the GraphWrapper object
- *
- * @param impl
- */
- public GraphWrapper(Graph impl)
- {
- this.impl = impl;
- }
-
- /**
- * Constructor for the GraphWrapper object
- */
- public GraphWrapper() { }
-
- /**
- * Sets the graph attribute of the GraphWrapper object
- */
- public void setGraph(Graph impl)
- {
- this.impl = impl;
- }
-
- // Graph Implementation. . .
- /**
- * Gets the vertices attribute of the GraphWrapper object
- */
- public Set getVertices()
- {
- return impl.getVertices();
- }
-
- /**
- * Gets the edges attribute of the GraphWrapper object
- */
- public Set getEdges()
- {
- return impl.getEdges();
- }
-
- /**
- * Gets the vertices attribute of the GraphWrapper object
- */
- public Set getVertices(Edge e)
- {
- return impl.getVertices(e);
- }
-
- /**
- * Gets the edges attribute of the GraphWrapper object
- */
- public Set getEdges(Vertex v)
- {
- return impl.getEdges(v);
- }
-}
+package org.apache.commons.graph.domain.basic;
+
+/**
+ * GraphWrapper This is a superclass of all Wrapper implementations. It
+ * basically does a redirection to the graph.
+ */
+
+import java.util.Set;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class GraphWrapper
+{
+ private Graph impl = null;
+
+ /**
+ * Constructor for the GraphWrapper object
+ *
+ * @param impl
+ */
+ public GraphWrapper(Graph impl)
+ {
+ this.impl = impl;
+ }
+
+ /**
+ * Constructor for the GraphWrapper object
+ */
+ public GraphWrapper() { }
+
+ /**
+ * Sets the graph attribute of the GraphWrapper object
+ */
+ public void setGraph(Graph impl)
+ {
+ this.impl = impl;
+ }
+
+ // Graph Implementation. . .
+ /**
+ * Gets the vertices attribute of the GraphWrapper object
+ */
+ public Set getVertices()
+ {
+ return impl.getVertices();
+ }
+
+ /**
+ * Gets the edges attribute of the GraphWrapper object
+ */
+ public Set getEdges()
+ {
+ return impl.getEdges();
+ }
+
+ /**
+ * Gets the vertices attribute of the GraphWrapper object
+ */
+ public Set getVertices(Edge e)
+ {
+ return impl.getVertices(e);
+ }
+
+ /**
+ * Gets the edges attribute of the GraphWrapper object
+ */
+ public Set getEdges(Vertex v)
+ {
+ return impl.getEdges(v);
+ }
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/GraphWrapper.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java Sat Feb 26 05:21:52 2005
@@ -1,5 +1,5 @@
-package org.apache.commons.graph.domain.basic;
-
+package org.apache.commons.graph.domain.basic;
+
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -14,201 +14,201 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-import java.util.Set;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import java.lang.reflect.*;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.exception.*;
-
-/**
- * Description of the Class
- */
-public class UndirectedGraphImpl
- implements UndirectedGraph,
- WeightedGraph,
- MutableGraph,
- InvocationHandler
-{
- private Set vertices = new HashSet();
- private Set edges = new HashSet();
-
- private Map edgeVerts = new HashMap();// EDGE X SET( VERTS )
- private Map vertEdges = new HashMap();// VERTEX X SET( EDGE )
- private Map edgeWeights = new HashMap(); // EDGE X WEIGHT
-
- /**
- * Constructor for the UndirectedGraphImpl object
- */
- public UndirectedGraphImpl() { }
-
- /**
- * Adds a feature to the Vertex attribute of the UndirectedGraphImpl object
- */
- public void addVertex(Vertex v)
- throws GraphException
- {
- vertices.add(v);
- }
-
- public void removeVertex( Vertex v )
- throws GraphException
- {
- vertices.remove( v );
- }
-
- public void removeEdge( Edge e )
- throws GraphException
- {
- edges.remove( e );
- }
-
- public void addEdge(Edge e)
- throws GraphException
- {
- edges.add( e );
- }
-
- public void disconnect(Edge e, Vertex v) {
- if (edgeVerts.containsKey( e )) {
- ((Set) edgeVerts.get( e )).remove( v );
- }
-
- if (vertEdges.containsKey( v )) {
- ((Set) vertEdges.get( v )).remove( e );
- }
- }
-
- public void connect( Edge e, Vertex v ) {
- Set verts = null;
- if (!edgeVerts.containsKey( e )) {
- verts = new HashSet();
- edgeVerts.put( e, verts );
- } else {
- verts = (Set) edgeVerts.get( e );
- }
-
- verts.add( v );
-
- Set edges = null;
- if (!vertEdges.containsKey( v )) {
- edges = new HashSet();
- vertEdges.put( v, edges );
- } else {
- edges = (Set) vertEdges.get( v );
- }
-
- edges.add( e );
-
- }
-
- /**
- * Adds a feature to the Edge attribute of the UndirectedGraphImpl object
- */
- public void addEdge(Edge e,
- Set vertices)
- throws GraphException
- {
- addEdge( e );
-
- Iterator verts = vertices.iterator();
- while (verts.hasNext()) {
- connect( e, (Vertex) verts.next() );
- }
- }
-
- // Interface Methods
- /**
- * Gets the vertices attribute of the UndirectedGraphImpl object
- */
- public Set getVertices()
- {
- return new HashSet(vertices);
- }
-
- /**
- * Gets the vertices attribute of the UndirectedGraphImpl object
- */
- public Set getVertices(Edge e)
- {
- if (edgeVerts.containsKey(e))
- {
- return new HashSet((Set) edgeVerts.get(e));
- }
- else
- {
- return new HashSet();
- }
- }
-
- /**
- * Gets the edges attribute of the UndirectedGraphImpl object
- */
- public Set getEdges()
- {
- return new HashSet(edges);
- }
-
- /**
- * Gets the edges attribute of the UndirectedGraphImpl object
- */
- public Set getEdges(Vertex v)
- {
- if (vertEdges.containsKey(v))
- {
- return new HashSet((Set) vertEdges.get(v));
- }
- else
- {
- return new HashSet();
- }
- }
-
- public void setWeight( Edge e, double w ) {
- if (edgeWeights.containsKey( e )) {
- edgeWeights.remove( e );
- }
-
- edgeWeights.put( e, new Double( w ) );
- }
-
- public double getWeight( Edge e ) {
- if (edgeWeights.containsKey( e )) {
- return ((Double) edgeWeights.get( e ) ).doubleValue();
- } else {
- return 1.0;
- }
- }
-
- /**
- * Description of the Method
- */
- public Object invoke(Object proxy,
- Method method,
- Object args[])
- throws Throwable
- {
- try {
- return method.invoke(this, args);
- } catch (InvocationTargetException ex) {
- throw ex.getTargetException();
- }
- }
-
-
-}
-
-
-
-
-
-
-
-
-
+ */
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import java.lang.reflect.*;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.exception.*;
+
+/**
+ * Description of the Class
+ */
+public class UndirectedGraphImpl
+ implements UndirectedGraph,
+ WeightedGraph,
+ MutableGraph,
+ InvocationHandler
+{
+ private Set vertices = new HashSet();
+ private Set edges = new HashSet();
+
+ private Map edgeVerts = new HashMap();// EDGE X SET( VERTS )
+ private Map vertEdges = new HashMap();// VERTEX X SET( EDGE )
+ private Map edgeWeights = new HashMap(); // EDGE X WEIGHT
+
+ /**
+ * Constructor for the UndirectedGraphImpl object
+ */
+ public UndirectedGraphImpl() { }
+
+ /**
+ * Adds a feature to the Vertex attribute of the UndirectedGraphImpl object
+ */
+ public void addVertex(Vertex v)
+ throws GraphException
+ {
+ vertices.add(v);
+ }
+
+ public void removeVertex( Vertex v )
+ throws GraphException
+ {
+ vertices.remove( v );
+ }
+
+ public void removeEdge( Edge e )
+ throws GraphException
+ {
+ edges.remove( e );
+ }
+
+ public void addEdge(Edge e)
+ throws GraphException
+ {
+ edges.add( e );
+ }
+
+ public void disconnect(Edge e, Vertex v) {
+ if (edgeVerts.containsKey( e )) {
+ ((Set) edgeVerts.get( e )).remove( v );
+ }
+
+ if (vertEdges.containsKey( v )) {
+ ((Set) vertEdges.get( v )).remove( e );
+ }
+ }
+
+ public void connect( Edge e, Vertex v ) {
+ Set verts = null;
+ if (!edgeVerts.containsKey( e )) {
+ verts = new HashSet();
+ edgeVerts.put( e, verts );
+ } else {
+ verts = (Set) edgeVerts.get( e );
+ }
+
+ verts.add( v );
+
+ Set edges = null;
+ if (!vertEdges.containsKey( v )) {
+ edges = new HashSet();
+ vertEdges.put( v, edges );
+ } else {
+ edges = (Set) vertEdges.get( v );
+ }
+
+ edges.add( e );
+
+ }
+
+ /**
+ * Adds a feature to the Edge attribute of the UndirectedGraphImpl object
+ */
+ public void addEdge(Edge e,
+ Set vertices)
+ throws GraphException
+ {
+ addEdge( e );
+
+ Iterator verts = vertices.iterator();
+ while (verts.hasNext()) {
+ connect( e, (Vertex) verts.next() );
+ }
+ }
+
+ // Interface Methods
+ /**
+ * Gets the vertices attribute of the UndirectedGraphImpl object
+ */
+ public Set getVertices()
+ {
+ return new HashSet(vertices);
+ }
+
+ /**
+ * Gets the vertices attribute of the UndirectedGraphImpl object
+ */
+ public Set getVertices(Edge e)
+ {
+ if (edgeVerts.containsKey(e))
+ {
+ return new HashSet((Set) edgeVerts.get(e));
+ }
+ else
+ {
+ return new HashSet();
+ }
+ }
+
+ /**
+ * Gets the edges attribute of the UndirectedGraphImpl object
+ */
+ public Set getEdges()
+ {
+ return new HashSet(edges);
+ }
+
+ /**
+ * Gets the edges attribute of the UndirectedGraphImpl object
+ */
+ public Set getEdges(Vertex v)
+ {
+ if (vertEdges.containsKey(v))
+ {
+ return new HashSet((Set) vertEdges.get(v));
+ }
+ else
+ {
+ return new HashSet();
+ }
+ }
+
+ public void setWeight( Edge e, double w ) {
+ if (edgeWeights.containsKey( e )) {
+ edgeWeights.remove( e );
+ }
+
+ edgeWeights.put( e, new Double( w ) );
+ }
+
+ public double getWeight( Edge e ) {
+ if (edgeWeights.containsKey( e )) {
+ return ((Double) edgeWeights.get( e ) ).doubleValue();
+ } else {
+ return 1.0;
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public Object invoke(Object proxy,
+ Method method,
+ Object args[])
+ throws Throwable
+ {
+ try {
+ return method.invoke(this, args);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java Sat Feb 26 05:21:52 2005
@@ -1,5 +1,5 @@
-package org.apache.commons.graph.domain.basic;
-
+package org.apache.commons.graph.domain.basic;
+
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -14,57 +14,57 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-/**
- * This is a simple wrapper to wrap around a graph, and create a weighted graph.
- */
-
-import java.util.Map;
-import java.util.HashMap;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class WeightedGraphWrapper
- extends GraphWrapper
- implements WeightedGraph
-{
- private Map weights = new HashMap();// EDGE X WEIGHT
-
- /**
- * Constructor for the WeightedGraphWrapper object
- *
- * @param graph
- */
- public WeightedGraphWrapper(Graph graph)
- {
- super(graph);
- }
-
- /**
- * Gets the weight attribute of the WeightedGraphWrapper object
- */
- public double getWeight(Edge e)
- {
- if (weights.containsKey(e))
- {
- return ((Double) weights.get(e)).doubleValue();
- }
- else
- {
- return 1.0;
- }
- }
-
- /**
- * Sets the weight attribute of the WeightedGraphWrapper object
- */
- public void setWeight(Edge e, double weight)
- {
- weights.put(e, new Double(weight));
- }
-
-}
+ */
+
+/**
+ * This is a simple wrapper to wrap around a graph, and create a weighted graph.
+ */
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class WeightedGraphWrapper
+ extends GraphWrapper
+ implements WeightedGraph
+{
+ private Map weights = new HashMap();// EDGE X WEIGHT
+
+ /**
+ * Constructor for the WeightedGraphWrapper object
+ *
+ * @param graph
+ */
+ public WeightedGraphWrapper(Graph graph)
+ {
+ super(graph);
+ }
+
+ /**
+ * Gets the weight attribute of the WeightedGraphWrapper object
+ */
+ public double getWeight(Edge e)
+ {
+ if (weights.containsKey(e))
+ {
+ return ((Double) weights.get(e)).doubleValue();
+ }
+ else
+ {
+ return 1.0;
+ }
+ }
+
+ /**
+ * Sets the weight attribute of the WeightedGraphWrapper object
+ */
+ public void setWeight(Edge e, double weight)
+ {
+ weights.put(e, new Double(weight));
+ }
+
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/Dependency.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/Dependency.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/Dependency.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/Dependency.java Sat Feb 26 05:21:52 2005
@@ -1,33 +1,33 @@
-package org.apache.commons.graph.domain.dependency;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class Dependency implements Edge
-{
- private Object head = null;
- private Object dep = null;
-
- /**
- * Constructor for the Dependency object
- *
- * @param head
- * @param dep
- */
- public Dependency(Object head,
- Object dep)
- {
- this.head = head;
- this.dep = dep;
- }
-
- /**
- * Description of the Method
- */
- public String description()
- {
- return head + " depends on " + dep;
- }
-}
+package org.apache.commons.graph.domain.dependency;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class Dependency implements Edge
+{
+ private Object head = null;
+ private Object dep = null;
+
+ /**
+ * Constructor for the Dependency object
+ *
+ * @param head
+ * @param dep
+ */
+ public Dependency(Object head,
+ Object dep)
+ {
+ this.head = head;
+ this.dep = dep;
+ }
+
+ /**
+ * Description of the Method
+ */
+ public String description()
+ {
+ return head + " depends on " + dep;
+ }
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/Dependency.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyGraph.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVertex.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVertex.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVertex.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVertex.java Sat Feb 26 05:21:52 2005
@@ -1,30 +1,30 @@
-package org.apache.commons.graph.domain.dependency;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class DependencyVertex
- implements Vertex
-{
- private Object value;
-
- /**
- * Constructor for the DependencyVertex object
- *
- * @param value
- */
- public DependencyVertex(Object value)
- {
- this.value = value;
- }
-
- /**
- * Gets the value attribute of the DependencyVertex object
- */
- public Object getValue()
- {
- return value;
- }
-}
+package org.apache.commons.graph.domain.dependency;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class DependencyVertex
+ implements Vertex
+{
+ private Object value;
+
+ /**
+ * Constructor for the DependencyVertex object
+ *
+ * @param value
+ */
+ public DependencyVertex(Object value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value attribute of the DependencyVertex object
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVertex.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVisitor.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVisitor.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVisitor.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVisitor.java Sat Feb 26 05:21:52 2005
@@ -1,84 +1,84 @@
-package org.apache.commons.graph.domain.dependency;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.algorithm.search.*;
-
-/**
- * Description of the Class
- */
-public class DependencyVisitor
- implements Visitor
-{
- private List deps = null;
- private DFS dfs = new DFS();
-
-
- /**
- * Constructor for the DependencyVisitor object
- */
- public DependencyVisitor() { }
-
- /**
- * Description of the Method
- */
- public void discoverGraph(Graph g) { }
-
- /**
- * Description of the Method
- */
- public void discoverVertex(Vertex v) { }
-
- /**
- * Description of the Method
- */
- public void discoverEdge(Edge e) { }
-
- /**
- * Description of the Method
- */
- public void finishGraph(Graph g) { }
-
- /**
- * Description of the Method
- */
- public void finishVertex(Vertex v)
- {
- if (v instanceof DependencyVertex)
- {
- deps.add(((DependencyVertex) v).getValue());
- }
- else
- {
- deps.add(v);
- }
- }
-
- /**
- * Description of the Method
- */
- public void finishEdge(Edge e) { }
-
- /**
- * Gets the sortedDependencies attribute of the DependencyVisitor object
- */
- public synchronized List
- getSortedDependencies(DependencyGraph dg,
- Vertex root)
- {
- deps = new LinkedList();
- dfs.visit(dg, root, this);
- return deps;
- }
-
- public synchronized List
- getSortedDependencies(DependencyGraph dg )
- {
- deps = new LinkedList();
- dfs.visit( dg, this );
- return deps;
- }
-}
-
+package org.apache.commons.graph.domain.dependency;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.algorithm.search.*;
+
+/**
+ * Description of the Class
+ */
+public class DependencyVisitor
+ implements Visitor
+{
+ private List deps = null;
+ private DFS dfs = new DFS();
+
+
+ /**
+ * Constructor for the DependencyVisitor object
+ */
+ public DependencyVisitor() { }
+
+ /**
+ * Description of the Method
+ */
+ public void discoverGraph(Graph g) { }
+
+ /**
+ * Description of the Method
+ */
+ public void discoverVertex(Vertex v) { }
+
+ /**
+ * Description of the Method
+ */
+ public void discoverEdge(Edge e) { }
+
+ /**
+ * Description of the Method
+ */
+ public void finishGraph(Graph g) { }
+
+ /**
+ * Description of the Method
+ */
+ public void finishVertex(Vertex v)
+ {
+ if (v instanceof DependencyVertex)
+ {
+ deps.add(((DependencyVertex) v).getValue());
+ }
+ else
+ {
+ deps.add(v);
+ }
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void finishEdge(Edge e) { }
+
+ /**
+ * Gets the sortedDependencies attribute of the DependencyVisitor object
+ */
+ public synchronized List
+ getSortedDependencies(DependencyGraph dg,
+ Vertex root)
+ {
+ deps = new LinkedList();
+ dfs.visit(dg, root, this);
+ return deps;
+ }
+
+ public synchronized List
+ getSortedDependencies(DependencyGraph dg )
+ {
+ deps = new LinkedList();
+ dfs.visit( dg, this );
+ return deps;
+ }
+}
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/DependencyVisitor.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/dependency/exception/CircularDependencyException.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ClassVertex.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ClassVertex.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ClassVertex.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ClassVertex.java Sat Feb 26 05:21:52 2005
@@ -1,41 +1,41 @@
-package org.apache.commons.graph.domain.jdepend;
-
-import java.awt.Color;
-
-import jdepend.framework.*;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.visualize.*;
-
-public class ClassVertex
- implements Vertex, Named, Colored
-{
- private JavaClass clazz = null;
-
- public ClassVertex( JavaClass clazz ) {
- this.clazz = clazz;
- }
-
- public JavaClass getJavaClass() {
- return clazz;
- }
-
- public String getName() {
- return clazz.getName();
- }
-
- public String toString() {
- return getName();
- }
-
- public Color getBackgroundColor() {
- return Color.blue;
- }
-
- public Color getTextColor() {
- return Color.white;
- }
-}
-
-
-
+package org.apache.commons.graph.domain.jdepend;
+
+import java.awt.Color;
+
+import jdepend.framework.*;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.visualize.*;
+
+public class ClassVertex
+ implements Vertex, Named, Colored
+{
+ private JavaClass clazz = null;
+
+ public ClassVertex( JavaClass clazz ) {
+ this.clazz = clazz;
+ }
+
+ public JavaClass getJavaClass() {
+ return clazz;
+ }
+
+ public String getName() {
+ return clazz.getName();
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public Color getBackgroundColor() {
+ return Color.blue;
+ }
+
+ public Color getTextColor() {
+ return Color.white;
+ }
+}
+
+
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ClassVertex.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ImportEdge.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ImportEdge.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ImportEdge.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ImportEdge.java Sat Feb 26 05:21:52 2005
@@ -1,35 +1,35 @@
-package org.apache.commons.graph.domain.jdepend;
-
-import org.apache.commons.graph.*;
-import jdepend.framework.*;
-
-public class ImportEdge
- implements Edge, Named
-{
- private JavaPackage pkg = null;
- private JavaClass clz = null;
-
- public ImportEdge( JavaClass clz,
- JavaPackage pkg) {
- this.pkg = pkg;
- this.clz = clz;
- }
-
- public JavaPackage getJavaPackage() {
- return pkg;
- }
-
- public JavaClass getJavaClass() {
- return clz;
- }
-
- public String getName() {
- return clz.getName() + " imports " + pkg.getName();
- }
-
- public String toString() {
- return getName();
- }
-}
-
-
+package org.apache.commons.graph.domain.jdepend;
+
+import org.apache.commons.graph.*;
+import jdepend.framework.*;
+
+public class ImportEdge
+ implements Edge, Named
+{
+ private JavaPackage pkg = null;
+ private JavaClass clz = null;
+
+ public ImportEdge( JavaClass clz,
+ JavaPackage pkg) {
+ this.pkg = pkg;
+ this.clz = clz;
+ }
+
+ public JavaPackage getJavaPackage() {
+ return pkg;
+ }
+
+ public JavaClass getJavaClass() {
+ return clz;
+ }
+
+ public String getName() {
+ return clz.getName() + " imports " + pkg.getName();
+ }
+
+ public String toString() {
+ return getName();
+ }
+}
+
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/ImportEdge.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/JDependGraph.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/JDependGraph.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/JDependGraph.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/JDependGraph.java Sat Feb 26 05:21:52 2005
@@ -1,92 +1,92 @@
-package org.apache.commons.graph.domain.jdepend;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import java.io.IOException;
-
-import jdepend.framework.*;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.domain.basic.*;
-
-public class JDependGraph
- extends DirectedGraphImpl
- implements DirectedGraph
-{
- private JDepend jdep = new JDepend();
- private Map pkgMap = new HashMap(); // JP X JPV
- private Map clazzMap = new HashMap(); // JC X JCV
-
- public JDependGraph( ) { }
-
- public void addDirectory( String directory )
- throws IOException
- {
- jdep.addDirectory( directory );
- }
-
- /**
- * This not only finds the PackageVertex, but also
- * adds it to the graph, if it isn't already there.
- */
- private PackageVertex findPackageVertex( JavaPackage pkg ) {
- if (pkgMap.containsKey( pkg.getName() )) {
- return (PackageVertex) pkgMap.get( pkg.getName() );
- } else {
- PackageVertex RC = new PackageVertex( pkg );
- pkgMap.put( pkg.getName(), RC );
- addVertex( RC );
- return RC;
- }
- }
-
- /**
- * This not only finds the PackageVertex, but also
- * adds it to the graph, if it isn't already there.
- */
- private ClassVertex findClassVertex( JavaClass clz ) {
- if (clazzMap.containsKey( clz )) {
- return (ClassVertex) clazzMap.get( clz );
- } else {
- ClassVertex RC = new ClassVertex( clz );
- clazzMap.put( clz, RC );
- addVertex( RC );
- return RC;
- }
- }
-
- public void analyze() {
- Iterator pkgs = jdep.analyze().iterator();
-
- while (pkgs.hasNext()) {
- JavaPackage pkg = (JavaPackage) pkgs.next();
- PackageVertex pv = findPackageVertex( pkg );
-
- Iterator clzs = pkg.getClasses().iterator();
- while (clzs.hasNext()) {
- JavaClass clz = (JavaClass) clzs.next();
- ClassVertex cv = findClassVertex( clz );
-
- OwnershipEdge oe = new OwnershipEdge( pkg, clz );
- addEdge( oe, pv, cv );
- setWeight( oe, 5.0 );
-
- Iterator ipkgs = clz.getImportedPackages().iterator();
- while (ipkgs.hasNext()) {
- JavaPackage ipkg = (JavaPackage) ipkgs.next();
- PackageVertex ipv = findPackageVertex( ipkg );
-
- ImportEdge ie = new ImportEdge( clz, pkg );
- addEdge( ie, cv, ipv );
- setWeight( ie, 200.0 * ipkg.afferentCoupling() + 100.0 );
- }
- }
- }
- }
-}
-
-
-
-
+package org.apache.commons.graph.domain.jdepend;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import java.io.IOException;
+
+import jdepend.framework.*;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.domain.basic.*;
+
+public class JDependGraph
+ extends DirectedGraphImpl
+ implements DirectedGraph
+{
+ private JDepend jdep = new JDepend();
+ private Map pkgMap = new HashMap(); // JP X JPV
+ private Map clazzMap = new HashMap(); // JC X JCV
+
+ public JDependGraph( ) { }
+
+ public void addDirectory( String directory )
+ throws IOException
+ {
+ jdep.addDirectory( directory );
+ }
+
+ /**
+ * This not only finds the PackageVertex, but also
+ * adds it to the graph, if it isn't already there.
+ */
+ private PackageVertex findPackageVertex( JavaPackage pkg ) {
+ if (pkgMap.containsKey( pkg.getName() )) {
+ return (PackageVertex) pkgMap.get( pkg.getName() );
+ } else {
+ PackageVertex RC = new PackageVertex( pkg );
+ pkgMap.put( pkg.getName(), RC );
+ addVertex( RC );
+ return RC;
+ }
+ }
+
+ /**
+ * This not only finds the PackageVertex, but also
+ * adds it to the graph, if it isn't already there.
+ */
+ private ClassVertex findClassVertex( JavaClass clz ) {
+ if (clazzMap.containsKey( clz )) {
+ return (ClassVertex) clazzMap.get( clz );
+ } else {
+ ClassVertex RC = new ClassVertex( clz );
+ clazzMap.put( clz, RC );
+ addVertex( RC );
+ return RC;
+ }
+ }
+
+ public void analyze() {
+ Iterator pkgs = jdep.analyze().iterator();
+
+ while (pkgs.hasNext()) {
+ JavaPackage pkg = (JavaPackage) pkgs.next();
+ PackageVertex pv = findPackageVertex( pkg );
+
+ Iterator clzs = pkg.getClasses().iterator();
+ while (clzs.hasNext()) {
+ JavaClass clz = (JavaClass) clzs.next();
+ ClassVertex cv = findClassVertex( clz );
+
+ OwnershipEdge oe = new OwnershipEdge( pkg, clz );
+ addEdge( oe, pv, cv );
+ setWeight( oe, 5.0 );
+
+ Iterator ipkgs = clz.getImportedPackages().iterator();
+ while (ipkgs.hasNext()) {
+ JavaPackage ipkg = (JavaPackage) ipkgs.next();
+ PackageVertex ipv = findPackageVertex( ipkg );
+
+ ImportEdge ie = new ImportEdge( clz, pkg );
+ addEdge( ie, cv, ipv );
+ setWeight( ie, 200.0 * ipkg.afferentCoupling() + 100.0 );
+ }
+ }
+ }
+ }
+}
+
+
+
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/JDependGraph.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/OwnershipEdge.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/OwnershipEdge.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/OwnershipEdge.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/OwnershipEdge.java Sat Feb 26 05:21:52 2005
@@ -1,39 +1,39 @@
-package org.apache.commons.graph.domain.jdepend;
-
-import org.apache.commons.graph.*;
-import jdepend.framework.*;
-
-public class OwnershipEdge
- implements Edge, Named
-{
- private JavaPackage pkg = null;
- private JavaClass clz = null;
-
- public OwnershipEdge( JavaPackage pkg,
- JavaClass clz) {
- this.pkg = pkg;
- this.clz = clz;
- }
-
- public JavaPackage getJavaPackage() {
- return pkg;
- }
-
- public JavaClass getJavaClass() {
- return clz;
- }
-
- public String getName() {
- return pkg.getName() + " owns " + clz.getName();
- }
-
- public String toString() {
- return getName();
- }
-
-}
-
-
-
-
-
+package org.apache.commons.graph.domain.jdepend;
+
+import org.apache.commons.graph.*;
+import jdepend.framework.*;
+
+public class OwnershipEdge
+ implements Edge, Named
+{
+ private JavaPackage pkg = null;
+ private JavaClass clz = null;
+
+ public OwnershipEdge( JavaPackage pkg,
+ JavaClass clz) {
+ this.pkg = pkg;
+ this.clz = clz;
+ }
+
+ public JavaPackage getJavaPackage() {
+ return pkg;
+ }
+
+ public JavaClass getJavaClass() {
+ return clz;
+ }
+
+ public String getName() {
+ return pkg.getName() + " owns " + clz.getName();
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+}
+
+
+
+
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/OwnershipEdge.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/PackageVertex.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/PackageVertex.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/PackageVertex.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/PackageVertex.java Sat Feb 26 05:21:52 2005
@@ -1,38 +1,38 @@
-package org.apache.commons.graph.domain.jdepend;
-
-import java.awt.Color;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.visualize.*;
-
-import jdepend.framework.*;
-
-public class PackageVertex
- implements Vertex, Named, Colored
-{
- private JavaPackage pkg = null;
-
- public PackageVertex( JavaPackage pkg ) {
- this.pkg = pkg;
- }
-
- public JavaPackage getJavaPackage() {
- return pkg;
- }
-
- public Color getBackgroundColor() {
- return Color.red;
- }
-
- public Color getTextColor() {
- return Color.white;
- }
-
- public String getName() {
- return pkg.getName();
- }
-
- public String toString() {
- return getName();
- }
-}
+package org.apache.commons.graph.domain.jdepend;
+
+import java.awt.Color;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.visualize.*;
+
+import jdepend.framework.*;
+
+public class PackageVertex
+ implements Vertex, Named, Colored
+{
+ private JavaPackage pkg = null;
+
+ public PackageVertex( JavaPackage pkg ) {
+ this.pkg = pkg;
+ }
+
+ public JavaPackage getJavaPackage() {
+ return pkg;
+ }
+
+ public Color getBackgroundColor() {
+ return Color.red;
+ }
+
+ public Color getTextColor() {
+ return Color.white;
+ }
+
+ public String getName() {
+ return pkg.getName();
+ }
+
+ public String toString() {
+ return getName();
+ }
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/jdepend/PackageVertex.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/State.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/State.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/State.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/State.java Sat Feb 26 05:21:52 2005
@@ -1,48 +1,48 @@
-package org.apache.commons.graph.domain.statemachine;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class State
- implements Vertex, Named
-{
- private String name;
- private StateMachine subMachine = null;
-
- /**
- * Constructor for the State object
- *
- * @param name
- */
- public State(String name)
- {
- this.name = name;
- }
-
- /**
- * Gets the name attribute of the State object
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Sets the submachine attribute of the State object
- */
- public void setSubmachine(StateMachine subMachine)
- {
- this.subMachine = subMachine;
- }
-
- /**
- * Gets the submachine attribute of the State object
- */
- public StateMachine getSubmachine()
- {
- return this.subMachine;
- }
-
-}
+package org.apache.commons.graph.domain.statemachine;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class State
+ implements Vertex, Named
+{
+ private String name;
+ private StateMachine subMachine = null;
+
+ /**
+ * Constructor for the State object
+ *
+ * @param name
+ */
+ public State(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Gets the name attribute of the State object
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Sets the submachine attribute of the State object
+ */
+ public void setSubmachine(StateMachine subMachine)
+ {
+ this.subMachine = subMachine;
+ }
+
+ /**
+ * Gets the submachine attribute of the State object
+ */
+ public StateMachine getSubmachine()
+ {
+ return this.subMachine;
+ }
+
+}
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/State.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/StateMachine.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/Transition.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/Transition.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/Transition.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/Transition.java Sat Feb 26 05:21:52 2005
@@ -1,121 +1,121 @@
-package org.apache.commons.graph.domain.statemachine;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class Transition
- implements Edge, Named
-{
- private String name;
- private State source;
- private State target;
-
- private String action = null;
- private String guard = null;
- private String output = null;
- private String trigger = null;
-
- /**
- * Description of the Field
- */
- public final static String EPSILON = "\u03B5";
-
- /**
- * Constructor for the Transition object
- *
- * @param name
- * @param source
- * @param target
- */
- public Transition(String name,
- State source,
- State target)
- {
- this.name = name;
- this.source = source;
- this.target = target;
- }
-
- /**
- * Gets the name attribute of the Transition object
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Gets the source attribute of the Transition object
- */
- public State getSource()
- {
- return source;
- }
-
- /**
- * Gets the target attribute of the Transition object
- */
- public State getTarget()
- {
- return target;
- }
-
- /**
- * Sets the action attribute of the Transition object
- */
- public void setTrigger( String trigger )
- {
- this.trigger = trigger;
- }
-
- /**
- * Sets the action attribute of the Transition object
- */
- public void setAction( String action )
- {
- this.action = action;
- }
-
- /**
- * Gets the action attribute of the Transition object
- */
- public String getAction()
- {
- return action;
- }
-
- /**
- * Sets the guard attribute of the Transition object
- */
- public void setGuard(String guard)
- {
- this.guard = guard;
- }
-
- /**
- * Gets the guard attribute of the Transition object
- */
- public String getGuard()
- {
- return guard;
- }
-
- /**
- * Gets the output attribute of the Transition object
- */
- public String getOutput()
- {
- return output;
- }
-
- /**
- * Sets the output attribute of the Transition object
- */
- public void setOutput(String output)
- {
- this.output = output;
- }
-}
-
+package org.apache.commons.graph.domain.statemachine;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class Transition
+ implements Edge, Named
+{
+ private String name;
+ private State source;
+ private State target;
+
+ private String action = null;
+ private String guard = null;
+ private String output = null;
+ private String trigger = null;
+
+ /**
+ * Description of the Field
+ */
+ public final static String EPSILON = "\u03B5";
+
+ /**
+ * Constructor for the Transition object
+ *
+ * @param name
+ * @param source
+ * @param target
+ */
+ public Transition(String name,
+ State source,
+ State target)
+ {
+ this.name = name;
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * Gets the name attribute of the Transition object
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Gets the source attribute of the Transition object
+ */
+ public State getSource()
+ {
+ return source;
+ }
+
+ /**
+ * Gets the target attribute of the Transition object
+ */
+ public State getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Sets the action attribute of the Transition object
+ */
+ public void setTrigger( String trigger )
+ {
+ this.trigger = trigger;
+ }
+
+ /**
+ * Sets the action attribute of the Transition object
+ */
+ public void setAction( String action )
+ {
+ this.action = action;
+ }
+
+ /**
+ * Gets the action attribute of the Transition object
+ */
+ public String getAction()
+ {
+ return action;
+ }
+
+ /**
+ * Sets the guard attribute of the Transition object
+ */
+ public void setGuard(String guard)
+ {
+ this.guard = guard;
+ }
+
+ /**
+ * Gets the guard attribute of the Transition object
+ */
+ public String getGuard()
+ {
+ return guard;
+ }
+
+ /**
+ * Gets the output attribute of the Transition object
+ */
+ public String getOutput()
+ {
+ return output;
+ }
+
+ /**
+ * Sets the output attribute of the Transition object
+ */
+ public void setOutput(String output)
+ {
+ this.output = output;
+ }
+}
+
Propchange: jakarta/commons/sandbox/graph2/trunk/src/java/org/apache/commons/graph/domain/statemachine/Transition.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org