net.xqhs.graphs.graph
Interface Graph

All Known Subinterfaces:
GraphMatchingPlatform.PlatformPrincipalGraph, GraphMatchingPlatform.PlatformShadowGraph
All Known Implementing Classes:
ContextGraph, ContextPattern, GMPImplementation.PrincipalGraph, GraphPattern, HyperGraph, SimpleGraph, TrackingGraph

public interface Graph

An interface representing a graph structure, using Node and Edge components.

Supports actions like adding and removing nodes and edges, getting the graph's size and lists of edges and nodes, filtering nodes by name, and testing if a node or edge belong to the graph.

Warning: depending on implementation, a Graph instance may not check if all edges have sources and destinations inside the graph.

Author:
Andrei Olaru

Method Summary
 Graph add(GraphComponent component)
           
 Graph addAll(java.util.Collection<? extends GraphComponent> components)
           
 Graph addEdge(Edge edge)
           
 Graph addNode(Node node)
           
 boolean contains(GraphComponent component)
           
 java.util.Collection<GraphComponent> getComponents()
           
 java.util.Collection<Edge> getEdges()
           
 java.util.Collection<Edge> getInEdges(Node node)
          Retrieves the edges going into the specified node.
 java.util.Collection<Node> getNodes()
           
 java.util.Collection<Node> getNodesNamed(java.lang.String name)
           
 java.util.Collection<Edge> getOutEdges(Node node)
          Retrieves the edges outgoing from the specified node.
 int m()
           
 int n()
           
 Graph remove(GraphComponent component)
           
 Graph removeAll(java.util.Collection<? extends GraphComponent> components)
           
 Graph removeEdge(Edge edge)
           
 Graph removeNode(Node node)
           
 int size()
           
 

Method Detail

addNode

Graph addNode(Node node)
Parameters:
node - - the Node to add.
Returns:
the graph itself, for chaining calls.

addEdge

Graph addEdge(Edge edge)
Parameters:
edge - - the Edge to add.
Returns:
the graph itself, for chained calls.

add

Graph add(GraphComponent component)
Parameters:
component - - the component to add. Must be an implementation of GraphComponent that the implementing class can recognize.
Returns:
the graph itself, for chained calls.

addAll

Graph addAll(java.util.Collection<? extends GraphComponent> components)
Parameters:
components - - the components to add. Each must be an implementation of GraphComponent that the implementing class can recognize.
Returns:
the graph itself, for chained calls.

removeNode

Graph removeNode(Node node)
Parameters:
node - - the Node to remove.
Returns:
the graph itself, for chained calls.

removeEdge

Graph removeEdge(Edge edge)
Parameters:
edge - - the Edge to remove.
Returns:
the graph itself, for chained calls.

remove

Graph remove(GraphComponent component)
Parameters:
component - - the component to remove. Must be an implementation of GraphComponent that the implementing class can recognize.
Returns:
the graph itself, for chained calls.

removeAll

Graph removeAll(java.util.Collection<? extends GraphComponent> components)
Parameters:
components - - the components to remove. Each must be an implementation of GraphComponent that the implementing class can recognize.
Returns:
the graph itself, for chained calls.

n

int n()
Returns:
the number of nodes in the graph

m

int m()
Returns:
the number of edges in the graph

size

int size()
Returns:
the size of the graph, in number of nodes

getNodes

java.util.Collection<Node> getNodes()
Returns:
the list of Node instances in the graph. May be an immutable collection.

getEdges

java.util.Collection<Edge> getEdges()
Returns:
the list of Edge instances in the graph. May be an immutable collection.

getComponents

java.util.Collection<GraphComponent> getComponents()
Returns:
the list of GraphComponent instances in the graph. May be an immutable collection.

getOutEdges

java.util.Collection<Edge> getOutEdges(Node node)
Retrieves the edges outgoing from the specified node.

Parameters:
node - - the node.
Returns:
the edges outgoing from the node.

getInEdges

java.util.Collection<Edge> getInEdges(Node node)
Retrieves the edges going into the specified node.

Parameters:
node - - the node.
Returns:
the edges going into the node.

contains

boolean contains(GraphComponent component)
Parameters:
component - - the component search for. Must be an implementation of GraphComponent that the implementing class can recognize.
Returns:
true if the component is contained; false otherwise.

getNodesNamed

java.util.Collection<Node> getNodesNamed(java.lang.String name)
Parameters:
name - - the name to search for.
Returns:
a Collection of Node instances with the required label.