net.xqhs.graphs.pattern
Class GraphPattern

java.lang.Object
  extended by net.xqhs.util.config.Config
      extended by net.xqhs.util.logging.Unit
          extended by net.xqhs.graphs.graph.SimpleGraph
              extended by net.xqhs.graphs.pattern.GraphPattern
All Implemented Interfaces:
Graph, net.xqhs.util.config.Configurable
Direct Known Subclasses:
ContextPattern

public class GraphPattern
extends SimpleGraph

Graph patterns are graphs that allow nodes with unspecified labels (marked with question marks) and edges labeled with regular expressions.

The class inherits from SimpleGraph, to which it is identical with the exception that it provides additional support for NodeP and EdgeP instances.

Author:
Andrei Olaru

Nested Class Summary
 
Nested classes/interfaces inherited from class net.xqhs.graphs.graph.SimpleGraph
SimpleGraph.NodeData
 
Nested classes/interfaces inherited from class net.xqhs.util.config.Config
net.xqhs.util.config.Config.ConfigLockedException
 
Field Summary
 
Fields inherited from class net.xqhs.graphs.graph.SimpleGraph
EDGE_LINE, EDGE_SEPARATOR, EDGE_TARGET, edges, nodes
 
Fields inherited from class net.xqhs.util.logging.Unit
DEFAULT_LEVEL, DEFAULT_UNIT_NAME
 
Constructor Summary
GraphPattern()
          Creates an empty graph pattern.
 
Method Summary
 GraphPattern addNode(Node node)
          Adds a node to the graph, but offers support for indexing NodeP instances (see addNode(NodeP, boolean)).
 GraphPattern addNode(Node node, boolean doindex)
          Adds a node to the graph, also indexing generic NodeP instances if required.
 int maxK()
          Get the maximum possible k for matches of this pattern.
 GraphPattern readFrom(java.io.InputStream input)
          Reads the structure of the graph as list of edges, adding all nodes appearing in the definition of edges.
 
Methods inherited from class net.xqhs.graphs.graph.SimpleGraph
add, addAll, addEdge, computeDistancesFromUndirected, contains, getComponents, getEdges, getInEdges, getNodes, getNodesNamed, getOutEdges, getUnitName, m, n, remove, removeAll, removeEdge, removeNode, size, toDot, toString
 
Methods inherited from class net.xqhs.util.logging.Unit
compose, dbg, doExit, getDefaultUnitName, l, le, lf, li, lock, lockedR, lr, lr, lw, setLink, setLink, setLogDisplay, setLogEnsureNew, setLoggerClass, setLoggerType, setLoggerTypeClass, setLogLevel, setLogReporter, setUnitName, setUnitName
 
Methods inherited from class net.xqhs.util.config.Config
build, ensureLocked, locked, lockedEx, makeDefaults
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphPattern

public GraphPattern()
Creates an empty graph pattern.

Method Detail

maxK

public int maxK()
Get the maximum possible k for matches of this pattern. Effectively, the number of edges in the pattern.

Returns:
the maximum value of k for a match.

addNode

public GraphPattern addNode(Node node)
Adds a node to the graph, but offers support for indexing NodeP instances (see addNode(NodeP, boolean)).

Generic nodes will be (re)indexed.

Specified by:
addNode in interface Graph
Overrides:
addNode in class SimpleGraph
Parameters:
node - - the Node to add.
Returns:
the graph itself, for chaining calls.

addNode

public GraphPattern addNode(Node node,
                            boolean doindex)
Adds a node to the graph, also indexing generic NodeP instances if required.

Warning: while the method allows not indexing the added generic nodes (by setting doindex to false), this is strongly discouraged and should be used with caution.

Parameters:
node - - the node to be added
doindex - - if set to true, and if the node is a generic NodeP, the node will be (re)indexed according to the pre-existing nodes in the graph
Returns:
the graph itself

readFrom

public GraphPattern readFrom(java.io.InputStream input)
Description copied from class: SimpleGraph
Reads the structure of the graph as list of edges, adding all nodes appearing in the definition of edges. The newly read edges and nodes are added on the existing structure, if any.

Overrides:
readFrom in class SimpleGraph
Parameters:
input - - a stream to read from
Returns:
the enriched SimpleGraph instance