You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/15 22:54:11 UTC
svn commit: r1136190 -
/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
Author: simonetripodi
Date: Wed Jun 15 20:54:10 2011
New Revision: 1136190
URL: http://svn.apache.org/viewvc?rev=1136190&view=rev
Log:
first checkin of DirectedMutableGraph class
Added:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java (with props)
Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java?rev=1136190&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java (added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java Wed Jun 15 20:54:10 2011
@@ -0,0 +1,96 @@
+package org.apache.commons.graph.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.graph.DirectedGraph;
+import org.apache.commons.graph.Edge;
+import org.apache.commons.graph.Vertex;
+
+/**
+ * A memory-based implementation of a mutable directed Graph.
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ */
+public class DirectedMutableGraph<V extends Vertex, E extends Edge<V>>
+ extends BaseMutableGraph<V, E>
+ implements DirectedGraph<V, E>
+{
+
+ private final Map<V, Set<E>> inbound = new HashMap<V, Set<E>>();
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<E> getInbound( V v )
+ {
+ return inbound.get( v );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<E> getOutbound( V v )
+ {
+ return getAdjacencyList().get( v );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void decorateAddVertex( V v )
+ {
+ inbound.put( v, new HashSet<E>() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void decorateRemoveVertex( V v )
+ {
+ inbound.remove( v );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void decorateAddEdge( E e )
+ {
+ inbound.get( e.getTail() ).add( e );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void decorateRemoveEdge( E e )
+ {
+ inbound.get( e.getTail() ).remove( e );
+ }
+
+}
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
------------------------------------------------------------------------------
svn:mime-type = text/plain