Skip to content
Snippets Groups Projects
Commit 887b82b4 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman :boom:
Browse files

CHECKPOINT: further refined the context package

parent 2ce7c5ab
No related branches found
No related tags found
No related merge requests found
Showing
with 158 additions and 146 deletions
......@@ -39,7 +39,7 @@ public abstract class AbstractAdjacencyGraph<
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>,
NEP extends Graph.NodeEndpoint<N, E>,
EEP extends Graph.EdgeEndpoint<N, E>
> extends AbstractCloud<Object,Graph.Endpoint<N,E,?>> implements Graph<N, E, NEP, EEP>
> extends AbstractCloud<Object,Graph.Endpoint<?, N,E>> implements Graph<N, E, NEP, EEP>
{
private static final Logger LOGGER = Logger.getLogger(AbstractAdjacencyGraph.class);
// private Set<E> edges;
......@@ -132,8 +132,8 @@ public abstract class AbstractAdjacencyGraph<
// lets see if this ContextEdge will allow itself to join the graph
if(this.contextEnabled
&& (attemptNode instanceof ContextGraphElement)
&& !((ContextGraphElement)attemptNode).joiningGraph(this) )
&& (attemptNode instanceof ContextGraphNode)
&& !((ContextGraphNode)attemptNode).joiningGraph(this) )
continue;
this.adjacentNodes.put(attemptNode, new ArrayList<N>());
......@@ -148,8 +148,8 @@ public abstract class AbstractAdjacencyGraph<
{
// lets see if this ContextEdge will allow itself to join the graph
if(this.contextEnabled
&& (attemptEdge instanceof ContextGraphElement)
&& !((ContextGraphElement)attemptEdge).joiningGraph(this) )
&& (attemptEdge instanceof ContextGraphNode)
&& !((ContextGraphNode)attemptEdge).joiningGraph(this) )
continue;
......@@ -303,8 +303,8 @@ public abstract class AbstractAdjacencyGraph<
throw new IllegalArgumentException("newEdge has a node as an end point that is not part of the graph");
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newEdge instanceof ContextGraphElement)
&& !((ContextGraphElement)newEdge).joiningGraph(this) )
if( this.isContextEnabled() && (newEdge instanceof ContextGraphNode)
&& !((ContextGraphNode)newEdge).joiningGraph(this) )
return false;
if( this.getInternalEdges().add(newEdge) )
......@@ -333,8 +333,8 @@ public abstract class AbstractAdjacencyGraph<
return false;
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newNode instanceof ContextGraphElement)
&& !((ContextGraphElement)newNode).joiningGraph(this) )
if( this.isContextEnabled() && (newNode instanceof ContextGraphNode)
&& !((ContextGraphNode)newNode).joiningGraph(this) )
return false;
this.getInternalAdjacencyEdges().put(newNode, new HashSet<E>());
......@@ -352,8 +352,8 @@ public abstract class AbstractAdjacencyGraph<
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (edgeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)edgeToRemove).leavingGraph(this) )
&& (edgeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)edgeToRemove).leavingGraph(this) )
return false;
if( !this.getInternalEdges().remove(edgeToRemove) )
......@@ -381,8 +381,8 @@ public abstract class AbstractAdjacencyGraph<
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (nodeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)nodeToRemove).leavingGraph(this) )
&& (nodeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)nodeToRemove).leavingGraph(this) )
return false;
final Set<E> removeEdges = this.getInternalAdjacencyEdges().get(nodeToRemove);
......@@ -467,8 +467,8 @@ public abstract class AbstractAdjacencyGraph<
{
// lets see if this ContextEdge will allow itself to join the graph
if(this.contextEnabled
&& (attemptNode instanceof ContextGraphElement)
&& !((ContextGraphElement)attemptNode).joiningGraph(cloneGraph) )
&& (attemptNode instanceof ContextGraphNode)
&& !((ContextGraphNode)attemptNode).joiningGraph(cloneGraph) )
continue;
cloneGraph.adjacentNodes.put(attemptNode, new ArrayList<N>());
......@@ -483,8 +483,8 @@ public abstract class AbstractAdjacencyGraph<
{
// lets see if this ContextEdge will allow itself to join the graph
if(this.contextEnabled
&& (attemptEdge instanceof ContextGraphElement)
&& !((ContextGraphElement)attemptEdge).joiningGraph(cloneGraph) )
&& (attemptEdge instanceof ContextGraphNode)
&& !((ContextGraphNode)attemptEdge).joiningGraph(cloneGraph) )
continue;
cloneGraph.edges.add(attemptEdge);
......@@ -606,12 +606,12 @@ public abstract class AbstractAdjacencyGraph<
}
@Override
public Set<Graph.Endpoint<N, E, ?>> getEndpoints()
public Set<Graph.Endpoint<?, N, E>> getEndpoints()
{
final Set<Graph.Endpoint<N,E,?>> endpoints = new HashSet<Graph.Endpoint<N,E,?>>();
final Set<Graph.Endpoint<?, N,E>> endpoints = new HashSet<Graph.Endpoint<?, N,E>>();
endpoints.addAll(this.getNodeEndpoints());
endpoints.addAll(this.getEdgeEndpoints());
return Collections.<Graph.Endpoint<N, E, ?>>unmodifiableSet(endpoints);
return Collections.<Graph.Endpoint<?, N, E>>unmodifiableSet(endpoints);
}
@Override
......@@ -978,7 +978,7 @@ public abstract class AbstractAdjacencyGraph<
}
*/
protected abstract class AbstractNodeEndpoint extends AbstractCloud<? super N,Graph.Endpoint<N,E,? super N>>.AbstractEndpoint<N> implements Graph.NodeEndpoint<N,E>
protected abstract class AbstractNodeEndpoint extends AbstractCloud<? super N,Graph.Endpoint<? super N, N,E>>.AbstractEndpoint<N> implements Graph.NodeEndpoint<N,E>
{
protected AbstractNodeEndpoint()
{
......@@ -1074,7 +1074,7 @@ public abstract class AbstractAdjacencyGraph<
}
};
protected abstract class AbstractEdgeEndpoint extends AbstractCloud<? super E,Graph.Endpoint<N,E,? super E>>.AbstractEndpoint<E> implements Graph.EdgeEndpoint<N,E>
protected abstract class AbstractEdgeEndpoint extends AbstractCloud<? super E,Graph.Endpoint<? super E, N,E>>.AbstractEndpoint<E> implements Graph.EdgeEndpoint<N,E>
{
protected AbstractEdgeEndpoint()
{
......
......@@ -24,7 +24,7 @@ import com.syncleus.dann.xml.NamedValueXml;
import com.syncleus.dann.xml.Namer;
import com.syncleus.dann.xml.XmlSerializable;
public abstract class AbstractBidirectedEdge<N, LN extends N, RN extends N> extends AbstractCloud<N> implements MixableBidirectedEdge<N, LN,RN>
public abstract class AbstractBidirectedEdge<N, LN extends N, RN extends N> extends AbstractEdge<N> implements MixableBidirectedEdge<N, LN,RN>
{
@Override
public abstract AbstractEndpoint<LN,RN> getLeftEndPoint();
......@@ -322,7 +322,7 @@ public abstract class AbstractBidirectedEdge<N, LN extends N, RN extends N> exte
};
}
protected abstract class AbstractEndpoint<EN extends N, ON extends N> extends AbstractCloud<N>.AbstractEndpoint<EN> implements MixableBidirectedEdge.Endpoint<N, EN,ON>
protected abstract class AbstractEndpoint<EN extends N, ON extends N> extends AbstractEdge<N>.AbstractEndpoint<EN> implements MixableBidirectedEdge.Endpoint<N, EN,ON>
{
private EN node = null;
private Direction direction;
......
/******************************************************************************
* *
* Copyright: (c) Syncleus, Inc. *
* *
* You may redistribute and modify this source code under the terms and *
* conditions of the Open Source Community License - Type C version 1.0 *
* or any later version as published by Syncleus, Inc. at www.syncleus.com. *
* There should be a copy of the license included with this file. If a copy *
* of the license is not included you are granted no right to distribute or *
* otherwise use this file except through a legal and valid license. You *
* should also contact Syncleus, Inc. at the information below if you cannot *
* find a license: *
* *
* Syncleus, Inc. *
* 2604 South 12th Street *
* Philadelphia, PA 19148 *
* *
******************************************************************************/
package com.syncleus.dann.graph;
public abstract class AbstractEdge<
T,
EP extends Edge.Endpoint<? extends T>
> extends AbstractCloud<T,EP> implements Edge<T,EP>
{
protected abstract class AbstractEndpoint<T> implements AbstractCloud.Endpoint<T>
{
}
}
......@@ -18,7 +18,7 @@
******************************************************************************/
package com.syncleus.dann.graph;
public abstract class AbstractHyperEdge<N> extends AbstractCloud<N> implements HyperEdge<N>
public abstract class AbstractHyperEdge<N> extends AbstractEdge<N> implements HyperEdge<N>
{
private static final long serialVersionUID = -3657973823101515199L;
......@@ -153,7 +153,7 @@ public abstract class AbstractHyperEdge<N> extends AbstractCloud<N> implements H
*/
}
protected abstract class AbstractEndpoint<EN extends N, ON extends N> extends AbstractCloud.AbstractEndpoint<EN> implements HyperEdge.Endpoint<N, EN>
protected abstract class AbstractEndpoint<EN extends N, ON extends N> extends AbstractEdge.AbstractEndpoint<EN> implements HyperEdge.Endpoint<N, EN>
{
private EN node = null;
......
......@@ -200,12 +200,12 @@ public abstract class AbstractMutableAdjacencyGraph<
}
@Override
public Map<?, Graph.Endpoint<N, E, ?>> reconfigure(Set<? extends N> addNodes, Set<? extends E> addEdges, Set<? extends Graph.Endpoint<?, ?, ?>> disconnectEndpoints) throws InvalidGraphException
public Map<?, Graph.Endpoint<?, N, E>> reconfigure(Set<? extends N> addNodes, Set<? extends E> addEdges, Set<? extends Graph.Endpoint<?, ?, ?>> disconnectEndpoints) throws InvalidGraphException
{
for(final Graph.Endpoint<?,?,?> disconnectEndpoint : disconnectEndpoints)
for(final Graph.Endpoint<?, ?,?> disconnectEndpoint : disconnectEndpoints)
this.adjacency.remove(disconnectEndpoint.getTarget());
Map<Object, Graph.Endpoint<N,E,?>> newEndpoints = new HashMap<Object, Graph.Endpoint<N, E, ?>>();
Map<Object, Graph.Endpoint<?, N,E>> newEndpoints = new HashMap<Object, Graph.Endpoint<?, N, E>>();
newEndpoints.putAll(this.joinNodes(addNodes));
newEndpoints.putAll(this.joinEdges(addEdges));
return newEndpoints;
......
......@@ -23,7 +23,7 @@ public interface AssignableGraph<
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>,
NEP extends AssignableGraph.NodeEndpoint<N, E>,
EEP extends AssignableGraph.EdgeEndpoint<N, E>
> extends Graph<N,E,NEP,EEP>, MutableEdge<Object,Graph.Endpoint<N,E,?>>
> extends Graph<N,E,NEP,EEP>, MutableEdge<Object,Graph.Endpoint<?, N,E>>
//public interface AssignableGraph<P extends Cloud<N>, N extends P, E extends P> extends Graph<N,E>, Cloud<P>, MutableEdge<P>
//public interface AssignableGraph<P extends AssignableGraph.Foo, N extends P, E extends Cloud<N> & AssignableGraph.Foo> extends Graph<N,E>, Cloud<P>, MutableEdge<P>
{
......
......@@ -20,7 +20,7 @@ package com.syncleus.dann.graph;
public interface Edge<
T,
EP extends Cloud.Endpoint<? extends T>
EP extends Edge.Endpoint<? extends T>
> extends Cloud<T,EP>
{
interface Endpoint<T> extends Cloud.Endpoint<T>
......
......@@ -18,8 +18,6 @@
******************************************************************************/
package com.syncleus.dann.graph;
import com.syncleus.dann.graph.context.ContextReporter;
import java.io.Serializable;
import java.util.Set;
/**
......@@ -38,48 +36,49 @@ import java.util.Set;
public interface Graph<
N,
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>,
NEP extends Graph.NodeEndpoint<N, E>,
EEP extends Graph.EdgeEndpoint<N, E>
> extends Cloud<Object,Graph.Endpoint<N,E,?>>
NE extends Graph.NodeEndpoint<N, E>,
EE extends Graph.EdgeEndpoint<N, E>
> extends Cloud<Object,Graph.Endpoint<?, N,E>>
{
interface Endpoint<
ON,
OE extends Cloud<ON,? extends Cloud.Endpoint<? extends ON>>,
T
> extends Cloud.Endpoint<T>
T,
N,
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>
>
extends Cloud.Endpoint<T>
{
Set<? extends Graph.Endpoint<ON,OE,?>> getAdjacent();
Set<? extends Graph.Endpoint<ON,OE,?>> getTraversableAdjacentTo();
Set<? extends Graph.Endpoint<ON,OE,?>> getTraversableAdjacentFrom();
Set<? extends Graph.Endpoint<?, N,E>> getAdjacent();
Set<? extends Graph.Endpoint<?, N,E>> getTraversableAdjacentTo();
Set<? extends Graph.Endpoint<?, N,E>> getTraversableAdjacentFrom();
Set<? extends Graph.NodeEndpoint<ON, OE>> getAdjacentNodes();
Set<? extends Graph.NodeEndpoint<ON, OE>> getTraversableAdjacentNodesTo();
Set<? extends Graph.NodeEndpoint<ON, OE>> getTraversableAdjacentNodesFrom();
Set<? extends Graph.NodeEndpoint<N, E>> getAdjacentNodes();
Set<? extends Graph.NodeEndpoint<N, E>> getTraversableAdjacentNodesTo();
Set<? extends Graph.NodeEndpoint<N, E>> getTraversableAdjacentNodesFrom();
Set<? extends Graph.EdgeEndpoint<ON, OE>> getAdjacentEdges();
Set<? extends Graph.EdgeEndpoint<ON, OE>> getTraversableAdjacentEdgesTo();
Set<? extends Graph.EdgeEndpoint<ON, OE>> getTraversableAdjacentEdgesFrom();
Set<? extends Graph.EdgeEndpoint<N, E>> getAdjacentEdges();
Set<? extends Graph.EdgeEndpoint<N, E>> getTraversableAdjacentEdgesTo();
Set<? extends Graph.EdgeEndpoint<N, E>> getTraversableAdjacentEdgesFrom();
};
interface NodeEndpoint<
ON,
OE extends Cloud<ON,? extends Cloud.Endpoint<? extends ON>>
> extends Graph.Endpoint<ON,OE,ON>
N,
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>
> extends Graph.Endpoint<N, N, E>
{
};
interface EdgeEndpoint<
ON,
OE extends Cloud<ON,? extends Cloud.Endpoint<? extends ON>>
> extends Graph.Endpoint<ON,OE,OE>
N,
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>
> extends Graph.Endpoint<E, N, E>
{
};
Set<EEP> getEdgeEndpoints();
Set<EEP> getEdgeEndpoints(Cloud<?,? extends Cloud.Endpoint<?>> cloud);
Set<EE> getEdgeEndpoints();
Set<EE> getEdgeEndpoints(Cloud<?,? extends Cloud.Endpoint<?>> cloud);
Set<NEP> getNodeEndpoints();
Set<NEP> getNodeEndpoints(Object node);
Set<NE> getNodeEndpoints();
Set<NE> getNodeEndpoints(Object node);
/**
* Get a set of all nodes in the graph.
......
......@@ -40,6 +40,7 @@ public final class MutableAdjacencyGraph<
@Override
protected MutableGraph.NodeEndpoint<N, E> createNodeEndpoint(N node) throws InvalidGraphException
{
return null;
}
@Override
......@@ -47,12 +48,4 @@ public final class MutableAdjacencyGraph<
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
private final class NodeEndpoint extends AbstractNodeEndpoint
{
}
private final class EdgeEndpoint extends AbstractEdgeEndpoint
{
}
}
......@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.syncleus.dann.graph.context.ContextGraphElement;
import com.syncleus.dann.graph.context.ContextGraphNode;
public class MutableDirectedAdjacencyGraph<N, E extends DirectedEdge<N>> extends AbstractDirectedAdjacencyGraph<N, E> implements MutableDirectedGraph<N, E>
{
......@@ -52,8 +52,8 @@ public class MutableDirectedAdjacencyGraph<N, E extends DirectedEdge<N>> extends
throw new IllegalArgumentException("newEdge has a node as an end point that is not part of the graph");
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newEdge instanceof ContextGraphElement)
&& !((ContextGraphElement)newEdge).joiningGraph(this) )
if( this.isContextEnabled() && (newEdge instanceof ContextGraphNode)
&& !((ContextGraphNode)newEdge).joiningGraph(this) )
return false;
if( this.getInternalEdges().add(newEdge) )
......@@ -83,8 +83,8 @@ public class MutableDirectedAdjacencyGraph<N, E extends DirectedEdge<N>> extends
return false;
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newNode instanceof ContextGraphElement)
&& !((ContextGraphElement)newNode).joiningGraph(this) )
if( this.isContextEnabled() && (newNode instanceof ContextGraphNode)
&& !((ContextGraphNode)newNode).joiningGraph(this) )
return false;
this.getInternalAdjacencyEdges().put(newNode, new HashSet<E>());
......@@ -103,8 +103,8 @@ public class MutableDirectedAdjacencyGraph<N, E extends DirectedEdge<N>> extends
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (edgeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)edgeToRemove).leavingGraph(this) )
&& (edgeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)edgeToRemove).leavingGraph(this) )
return false;
if( !this.getInternalEdges().remove(edgeToRemove) )
......@@ -133,8 +133,8 @@ public class MutableDirectedAdjacencyGraph<N, E extends DirectedEdge<N>> extends
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (nodeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)nodeToRemove).leavingGraph(this) )
&& (nodeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)nodeToRemove).leavingGraph(this) )
return false;
final Set<E> removeEdges = this.getInternalAdjacencyEdges().get(nodeToRemove);
......
......@@ -24,14 +24,14 @@ import java.util.Set;
public interface MutableGraph<
N,
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>,
NEP extends MutableGraph.NodeEndpoint<N, E>,
EEP extends MutableGraph.EdgeEndpoint<N, E>
> extends AssignableGraph<N,E,NEP,EEP>
NE extends MutableGraph.NodeEndpoint<N, E>,
EE extends MutableGraph.EdgeEndpoint<N, E>
> extends AssignableGraph<N,E,NE,EE>
{
interface NodeEndpoint<
ON,
OE extends Cloud<ON,? extends Cloud.Endpoint<? extends ON>>
> extends AssignableGraph.NodeEndpoint<ON,OE>
N,
E extends Cloud<N,? extends Cloud.Endpoint<? extends N>>
> extends AssignableGraph.NodeEndpoint<N,E>
{
};
......@@ -42,20 +42,20 @@ public interface MutableGraph<
{
};
NEP joinNode(N node) throws InvalidGraphException;
Map<N, NEP> joinNodes(Set<? extends N> nodes) throws InvalidGraphException;
Map<N, Set<NEP>> joinNodes(Map<? extends N,? extends Integer> nodes) throws InvalidGraphException;
Set<EEP> leaveNode(MutableGraph.NodeEndpoint<?, ? extends Cloud<?,? extends Cloud.Endpoint<?>>> endpoint) throws InvalidGraphException;
Set<EEP> leaveNodes(Set<? extends MutableGraph.NodeEndpoint<?, ? extends Cloud<?,? extends Cloud.Endpoint<?>>>> endpoint) throws InvalidGraphException;
NE joinNode(N node) throws InvalidGraphException;
Map<N, NE> joinNodes(Set<? extends N> nodes) throws InvalidGraphException;
Map<N, Set<NE>> joinNodes(Map<? extends N,? extends Integer> nodes) throws InvalidGraphException;
Set<EE> leaveNode(MutableGraph.NodeEndpoint<?, ? extends Cloud<?,? extends Cloud.Endpoint<?>>> endpoint) throws InvalidGraphException;
Set<EE> leaveNodes(Set<? extends MutableGraph.NodeEndpoint<?, ? extends Cloud<?,? extends Cloud.Endpoint<?>>>> endpoint) throws InvalidGraphException;
EEP joinEdge(E edge) throws InvalidGraphException;
Map<E, EEP> joinEdges(Set<? extends E> edges) throws InvalidGraphException;
Map<E, Set<EEP>> joinEdges(Map<? extends E,? extends Integer> edges) throws InvalidGraphException;
EE joinEdge(E edge) throws InvalidGraphException;
Map<E, EE> joinEdges(Set<? extends E> edges) throws InvalidGraphException;
Map<E, Set<EE>> joinEdges(Map<? extends E,? extends Integer> edges) throws InvalidGraphException;
void leaveEdge(MutableGraph.EdgeEndpoint<?, ? extends Cloud<?,? extends Cloud.Endpoint<?>>> endpoint) throws InvalidGraphException;
void leaveEdges(Set<? extends MutableGraph.EdgeEndpoint<?, ? extends Cloud<?,? extends Cloud.Endpoint<?>>>> endpoints) throws InvalidGraphException;
void clear() throws InvalidGraphException;
void clearEdges() throws InvalidGraphException;
Map<?, Graph.Endpoint<N,E,?>> reconfigure(Set<? extends N> addNodes, Set<? extends E> addEdges, final Set<? extends Graph.Endpoint<?,?,?>> disconnectEndpoints) throws InvalidGraphException;
Map<?, Graph.Endpoint<?, N,E>> reconfigure(Set<? extends N> addNodes, Set<? extends E> addEdges, final Set<? extends Graph.Endpoint<?, ?,?>> disconnectEndpoints) throws InvalidGraphException;
}
......@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.syncleus.dann.graph.context.ContextGraphElement;
import com.syncleus.dann.graph.context.ContextGraphNode;
public class MutableHyperAdjacencyGraph<N, E extends HyperEdge<N>> extends AbstractHyperAdjacencyGraph<N, E> implements MutableHyperGraph<N, E>
{
......@@ -52,8 +52,8 @@ public class MutableHyperAdjacencyGraph<N, E extends HyperEdge<N>> extends Abstr
throw new IllegalArgumentException("newEdge has a node as an end point that is not part of the graph");
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newEdge instanceof ContextGraphElement)
&& !((ContextGraphElement)newEdge).joiningGraph(this) )
if( this.isContextEnabled() && (newEdge instanceof ContextGraphNode)
&& !((ContextGraphNode)newEdge).joiningGraph(this) )
return false;
if( this.getInternalEdges().add(newEdge) )
......@@ -83,8 +83,8 @@ public class MutableHyperAdjacencyGraph<N, E extends HyperEdge<N>> extends Abstr
return false;
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newNode instanceof ContextGraphElement)
&& !((ContextGraphElement)newNode).joiningGraph(this) )
if( this.isContextEnabled() && (newNode instanceof ContextGraphNode)
&& !((ContextGraphNode)newNode).joiningGraph(this) )
return false;
this.getInternalAdjacencyEdges().put(newNode, new HashSet<E>());
......@@ -103,8 +103,8 @@ public class MutableHyperAdjacencyGraph<N, E extends HyperEdge<N>> extends Abstr
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (edgeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)edgeToRemove).leavingGraph(this) )
&& (edgeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)edgeToRemove).leavingGraph(this) )
return false;
if( !this.getInternalEdges().remove(edgeToRemove) )
......@@ -133,8 +133,8 @@ public class MutableHyperAdjacencyGraph<N, E extends HyperEdge<N>> extends Abstr
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (nodeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)nodeToRemove).leavingGraph(this) )
&& (nodeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)nodeToRemove).leavingGraph(this) )
return false;
final Set<E> removeEdges = this.getInternalAdjacencyEdges().get(nodeToRemove);
......
......@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.syncleus.dann.graph.context.ContextGraphElement;
import com.syncleus.dann.graph.context.ContextGraphNode;
public class MutableRootedTreeAdjacencyGraph<N, E extends DirectedEdge<N>> extends AbstractRootedTreeAdjacencyGraph<N, E> implements MutableRootedTreeGraph<N, E>
{
......@@ -52,8 +52,8 @@ public class MutableRootedTreeAdjacencyGraph<N, E extends DirectedEdge<N>> exten
throw new IllegalArgumentException("newEdge has a node as an end point that is not part of the graph");
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newEdge instanceof ContextGraphElement)
&& !((ContextGraphElement)newEdge).joiningGraph(this) )
if( this.isContextEnabled() && (newEdge instanceof ContextGraphNode)
&& !((ContextGraphNode)newEdge).joiningGraph(this) )
return false;
if( this.getInternalEdges().add(newEdge) )
......@@ -83,8 +83,8 @@ public class MutableRootedTreeAdjacencyGraph<N, E extends DirectedEdge<N>> exten
return false;
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newNode instanceof ContextGraphElement)
&& !((ContextGraphElement)newNode).joiningGraph(this) )
if( this.isContextEnabled() && (newNode instanceof ContextGraphNode)
&& !((ContextGraphNode)newNode).joiningGraph(this) )
return false;
this.getInternalAdjacencyEdges().put(newNode, new HashSet<E>());
......@@ -103,8 +103,8 @@ public class MutableRootedTreeAdjacencyGraph<N, E extends DirectedEdge<N>> exten
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (edgeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)edgeToRemove).leavingGraph(this) )
&& (edgeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)edgeToRemove).leavingGraph(this) )
return false;
if( !this.getInternalEdges().remove(edgeToRemove) )
......@@ -133,8 +133,8 @@ public class MutableRootedTreeAdjacencyGraph<N, E extends DirectedEdge<N>> exten
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (nodeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)nodeToRemove).leavingGraph(this) )
&& (nodeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)nodeToRemove).leavingGraph(this) )
return false;
final Set<E> removeEdges = this.getInternalAdjacencyEdges().get(nodeToRemove);
......
......@@ -18,7 +18,7 @@
******************************************************************************/
package com.syncleus.dann.graph;
import com.syncleus.dann.graph.context.ContextGraphElement;
import com.syncleus.dann.graph.context.ContextGraphNode;
import com.syncleus.dann.graph.tree.Trees;
import java.util.ArrayList;
import java.util.HashSet;
......@@ -61,8 +61,8 @@ public class MutableTreeAdjacencyGraph<N, E extends BidirectedEdge<N>> extends A
throw new IllegalArgumentException("adding newEdge can not be added because this graph would no longer be a tree");
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newEdge instanceof ContextGraphElement)
&& !((ContextGraphElement)newEdge).joiningGraph(this) )
if( this.isContextEnabled() && (newEdge instanceof ContextGraphNode)
&& !((ContextGraphNode)newEdge).joiningGraph(this) )
return false;
if( this.getInternalEdges().add(newEdge) )
......@@ -92,8 +92,8 @@ public class MutableTreeAdjacencyGraph<N, E extends BidirectedEdge<N>> extends A
return false;
// if context is enabled lets check if it can join
if( this.isContextEnabled() && (newNode instanceof ContextGraphElement)
&& !((ContextGraphElement)newNode).joiningGraph(this) )
if( this.isContextEnabled() && (newNode instanceof ContextGraphNode)
&& !((ContextGraphNode)newNode).joiningGraph(this) )
return false;
this.getInternalAdjacencyEdges().put(newNode, new HashSet<E>());
......@@ -112,8 +112,8 @@ public class MutableTreeAdjacencyGraph<N, E extends BidirectedEdge<N>> extends A
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (edgeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)edgeToRemove).leavingGraph(this) )
&& (edgeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)edgeToRemove).leavingGraph(this) )
return false;
if( !this.getInternalEdges().remove(edgeToRemove) )
......@@ -142,8 +142,8 @@ public class MutableTreeAdjacencyGraph<N, E extends BidirectedEdge<N>> extends A
// if context is enabled lets check if it can join
if( this.isContextEnabled()
&& (nodeToRemove instanceof ContextGraphElement)
&& !((ContextGraphElement)nodeToRemove).leavingGraph(this) )
&& (nodeToRemove instanceof ContextGraphNode)
&& !((ContextGraphNode)nodeToRemove).leavingGraph(this) )
return false;
final Set<E> removeEdges = this.getInternalAdjacencyEdges().get(nodeToRemove);
......
......@@ -24,7 +24,7 @@ import java.util.Set;
import java.io.Serializable;
import com.syncleus.dann.graph.Graph;
public abstract class AbstractContextGraphElement<G extends Graph<?, ?>> implements ContextGraphElement<G>, Serializable
public abstract class AbstractContextGraphElement<G extends Graph<?, ?>> implements ContextGraphNode<G>, Serializable
{
private final boolean allowJoiningMultipleGraphs;
private final Set<G> joinedGraphs = new HashSet<G>();
......
......@@ -21,10 +21,8 @@ package com.syncleus.dann.graph.context;
import java.util.Set;
import com.syncleus.dann.graph.Cloud;
public interface ContextElement<
E extends Cloud<?, ? extends Cloud.Endpoint<?>>
>
public interface ContextCloudElement< CE extends Cloud.Endpoint<?> >
{
void changingContext(Set<? extends E> joiningContexts, Set<? extends Cloud<?,? extends Cloud.Endpoint<?>>> leavingContexts) throws RejectedContextException;
void changedContext(Set<? extends E> joinedContexts, Set<? extends Cloud<?,? extends Cloud.Endpoint<?>>> leftContexts);
void changingCloudContext(Set<? extends CE> joiningContexts, Set<? extends Cloud<?,? extends Cloud.Endpoint<?>>> leavingContexts) throws RejectedContextException;
void changedCloudContext(Set<? extends CE> joinedContexts, Set<? extends Cloud<?,? extends Cloud.Endpoint<?>>> leftContexts);
}
......@@ -19,10 +19,10 @@
package com.syncleus.dann.graph.context;
import java.util.Set;
import com.syncleus.dann.graph.Cloud;
import com.syncleus.dann.graph.*;
public interface ContextNode<N, E extends Cloud<N>>
public interface ContextEdgeElement< EE extends Edge.Endpoint<?> >
{
void changingConnectedEdges(Set<E> connectingEdges, Set<E> disconnectingEdges) throws RejectedContextException;
void changedConnectedEdges(Set<E> connectedEdges, Set<E> disconnectedEdges);
}
void changingEdgeContext( Set<? extends EE> joiningContexts, Set<?> leavingContexts) throws RejectedContextException;
void changedEdgeContext(Set<? extends EE> joinedContexts, Set<?> leftContexts);
}
\ No newline at end of file
......@@ -20,9 +20,10 @@ package com.syncleus.dann.graph.context;
import java.util.Set;
import com.syncleus.dann.graph.Cloud;
import com.syncleus.dann.graph.Graph;
public interface GraphEdgeContextElement
public interface ContextGraphEdge< GEE extends Graph.EdgeEndpoint<?,?> >
{
void changingEdgeContext(Set<? extends E> joinedGraphContexts, Set<? extends Cloud<?,? extends Cloud.Endpoint<?>>> leftGraphContexts);
void changedEdgeContext(Set<? extends E> joinedGraphContexts, Set<? extends Cloud<?,? extends Cloud.Endpoint<?>>> leftGraphContexts);
void changingGraphEdgeContext( Set<? extends GEE> joiningContexts, Set<?> leavingContexts) throws RejectedContextException;
void changedGraphEdgeContext(Set<? extends GEE> joinedContexts, Set<?> leftContexts);
}
......@@ -21,8 +21,8 @@ package com.syncleus.dann.graph.context;
import java.util.Set;
import com.syncleus.dann.graph.Graph;
public interface ContextGraphElement<G extends Graph<?, ?>>
public interface ContextGraphElement< GE extends Graph.Endpoint<?, ?,?> >
{
void changingJoinedGraphs(Set<G> joiningGraphs, Set<G> leavingGraphs) throws RejectedContextException;
void changedJoinedGraphs(Set<G> joinedGraphs, Set<G> leftGraphs);
void changingGraphContext( Set<? extends GE> joiningAsNode, Set<? extends GE> joiningAsEdge, Set<?> leavingContexts) throws RejectedContextException;
void changedGraphContext(Set<? extends GE> joinedAsNode, Set<? extends GE> joinedAsEdge, Set<?> leftContexts);
}
......@@ -19,18 +19,10 @@
package com.syncleus.dann.graph.context;
import java.util.Set;
import com.syncleus.dann.graph.Cloud;
import com.syncleus.dann.graph.Graph;
public interface GraphContextElement<
G extends Graph<
?,
Cloud<?,? extends Cloud.Endpoint<?>>,
? extends Graph.NodeEndpoint<?,?>,
? extends Graph.EdgeEndpoint<?,?>
>
>
public interface ContextGraphNode< GNE extends Graph.NodeEndpoint<?,?> >
{
void changingNodeContext( Set<? extends G> joiningGraphContexts, Set<?> leavingGraphContexts) throws RejectedContextException;
void changedNodeContext(Set<? extends G> joinedGraphContexts, Set<?> leftGraphContexts);
void changingGraphNodeContext( Set<? extends GNE> joiningContexts, Set<?> leavingContexts) throws RejectedContextException;
void changedGraphNodeContext(Set<? extends GNE> joinedContexts, Set<?> leftContexts);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment