Hi Patrik,
there is a lot of commits in your lab, maybe it would be cool to have
a small intro on what you are doing and what the status of the algos
are?
/peter
On Thu, May 22, 2008 at 7:17 PM, <[EMAIL PROTECTED]> wrote:
> Author: patrik
> Date: 2008-05-22 19:17:29 +0200 (Thu, 22 May 2008)
> New Revision: 1597
>
> Log:
> Various experimental subgraph implementations
>
> Added:
>
> laboratory/users/patrik/neoalgo/trunk/src/main/java/org/neo4j/algo/graphGeneration/SubNetwork.java
>
> laboratory/users/patrik/neoalgo/trunk/src/main/java/org/neo4j/algo/graphGeneration/SubNetworkCopy.java
>
> Added:
> laboratory/users/patrik/neoalgo/trunk/src/main/java/org/neo4j/algo/graphGeneration/SubNetwork.java
> ===
> ---
> laboratory/users/patrik/neoalgo/trunk/src/main/java/org/neo4j/algo/graphGeneration/SubNetwork.java
> (rev 0)
> +++
> laboratory/users/patrik/neoalgo/trunk/src/main/java/org/neo4j/algo/graphGeneration/SubNetwork.java
> 2008-05-22 17:17:29 UTC (rev 1597)
> @@ -0,0 +1,603 @@
> +package org.neo4j.algo.graphGeneration;
> +
> +import java.util.HashMap;
> +import java.util.HashSet;
> +import java.util.LinkedList;
> +import java.util.List;
> +import java.util.Map;
> +import java.util.Set;
> +import org.neo4j.api.core.Direction;
> +import org.neo4j.api.core.Node;
> +import org.neo4j.api.core.Relationship;
> +import org.neo4j.api.core.RelationshipType;
> +import org.neo4j.api.core.ReturnableEvaluator;
> +import org.neo4j.api.core.StopEvaluator;
> +import org.neo4j.api.core.TraversalPosition;
> +import org.neo4j.api.core.Traverser;
> +import org.neo4j.api.core.Traverser.Order;
> +import org.neo4j.impl.traversal.TraverserFactory;
> +
> +/**
> + * This class can be used to represent part of a network (like a subgraph),
> + * represented as a set of nodes and a set of edges. All this really does is
> + * filter the results of Node.getRelationships to only return relationships
> + * within this subnetwork, thus limiting traversals and searches to the nodes
> + * within the subnetwork. Therefore, any changes made to the subnetwork will
> be
> + * reflected in the underlying network as well. The subgraph always starts
> out
> + * empty, and can be emptied again with the clear() method. It can then be
> + * filled with nodes and edges through the various methods supplied. This
> class
> + * can of course also be used to retrieve the set of all nodes and the set of
> + * all edges from a network.
> + * @author Patrik Larsson
> + */
> +public class SubNetwork
> +{
> +Set subNetworkRelationships = new HashSet();
> +Set subNetworkNodes = new HashSet();
> +TraverserFactory traverserFactory = new TraverserFactory();
> +
> +/**
> + * Adds a tree to this subnetwork by doing a breadth first search of a
> given
> + * depth, adding all nodes found and the first edge leading to each node.
> + * @param node
> + *The starting node
> + * @param searchDepth
> + *The search depth.
> + * @param relationshipType
> + *Relation type to traverse.
> + * @param direction
> + *Direction in which to traverse relationships.
> + */
> +public void addTreeFromCentralNode( Node node, final int searchDepth,
> +RelationshipType relationshipType, Direction direction )
> +{
> +Traverser traverser = node.traverse( Order.BREADTH_FIRST,
> +new StopEvaluator()
> +{
> +public boolean isStopNode( TraversalPosition currentPos )
> +{
> +return currentPos.depth() >= searchDepth;
> +}
> +}, ReturnableEvaluator.ALL, relationshipType, direction );
> +for ( Node node2 : traverser )
> +{
> +subNetworkNodes.add( node2 );
> +subNetworkRelationships.add( traverser.currentPosition()
> +.lastRelationshipTraversed() );
> +}
> +}
> +
> +/**
> + * Makes a search of a given depth from a given node and adds all found
> + * nodes and relationships to this subnetwork.
> + * @param node
> + *The starting node
> + * @param searchDepth
> + *The search depth.
> + * @param relationshipType
> + *Relation type to traverse.
> + * @param direction
> + *Direction in which to traverse relationships.
> + * @param includeBoundaryRelationships
> + *If false, relationships between nodes where the maximum
> depth
> + *has been reached will not be included since the search
> depth
> + *is considered to have been exhausted at them.
> + */
> +public void addSubNetworkFromCentralNode( Node node, final int
> searchDepth,
> +RelationshipType relationshipType, Direction direction,
> +boolean includeBoundaryRelationships )
> +{