Class Subgraph

java.lang.Object
  |
  +--MusicGraph
        |
        +--Subgraph
Direct Known Subclasses:
NonSeqSubgraph, SeqSubgraph

public abstract class Subgraph
extends MusicGraph

A Subgraph is basically a subset of vertices and a subset of edges of some MotherGraph. The Subgraph class is abstract because in the SimFinder system, a subgraph is either sequential (SeqSubgraph) or non-sequential (NonSeqSubgraph). The two kinds do have some common properties and methods, though, and these are described in this abstract Subgraph class.


Field Summary
protected  MotherGraph mothergraph
          The MotherGraph that owns the vertices and edges pointed to by this Subgraph.
 
Fields inherited from class MusicGraph
edges, title, vertices
 
Constructor Summary
Subgraph()
           
 
Method Summary
 void addVertexAndNecessaryEdges(MusicVertex mv, MusicEdge me)
          Adds a given MusicVertex mv and a MusicEdge me to this Subgraph along with any MusicEdges in the MotherGraph that connect mv to the rest of this Subgraph.
abstract  void extend(int times)
          Extends this subgraph by randomly adding to it a MusicVertex which is connected to this subgraph in its mother graph.
 MusicEdge findEdgeConnectingToVertex(MusicVertex mv)
          If mv is outside this subgraph, and there is an edge e in the mothergraph connecting mv to some vertex in this subgraph, this method returns e, otherwise null.
 java.util.Vector getAllProperFollowInEdges(boolean includeWeakEdges)
          Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper follow in-edges of MusicVertex i in this Subgraph; proper follow in-edges are follow in-edges to the given vertex that are also contained in this Subgraph.
 java.util.Vector getAllProperFollowOutEdges(boolean includeWeakEdges)
          Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper follow out-edges of MusicVertex i in this Subgraph; proper follow out-edges are follow out-edges to the given vertex that are also contained in this Subgraph.
 java.util.Vector getAllProperInEdges(boolean includeWeakEdges)
          Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper in-edges of MusicVertex i in this Subgraph; proper in-edges are in-edges to the given vertex that are also contained in this Subgraph.
 java.util.Vector getAllProperOutEdges(boolean includeWeakEdges)
          Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper out-edges of MusicVertex i in this Subgraph; proper out-edges are out-edges to the given vertex that are also contained in this Subgraph.
 java.util.Vector getAllSons(java.util.Vector vert)
          Returns a Vector of MusicVertex which follow upon any of the music vertices in the input vector, i.e. there is a FOLLOWS MusicEdge from the vertex in the input vector to the one in the output vector.
 java.util.Vector getFollowEdges()
          Returns a Vector of all FOLLOW edges in this Subgraph.
abstract  int getLeftExtensibility()
          Returns how many times this Subgraph may be extended to the left.
 MotherGraph getMotherGraph()
          Returns the MotherGraph of this Subgraph.
abstract  double getMothergraphCoverage()
           
abstract  int getRightExtensibility()
          Returns how many times this Subgraph may be extended to the right.
 jm.music.data.Score getScore()
          Returns the Score object that the MotherGraph of this Subgraph originated from.
 java.util.Vector getSimultaneousEdges()
          Returns a Vector of all SIMULTANEOUS edges in this Subgraph.
 java.util.Vector getStrongFollowEdges()
          Returns a Vector of all strong FOLLOW edges in this Subgraph.
 java.util.Vector getStrongSimultaneousEdges()
          Returns a Vector of all strong SIMULTANEOUS edges in this Subgraph.
 boolean isStrongSequential()
          Returns true if this Subgraph is sequential with only strong FOLLOW edges.
abstract  int numberOfLeftmostRests()
           
abstract  int numberOfRightmostRests()
           
 void printTheScore(java.lang.String label)
          For debugging.
 void removeVertexAndConnectedEdges(MusicVertex mv)
          Removes a given MusicVertex mv from this Subgraph along with any MusicEdges that connected mv to the rest of this Subgraph.
abstract  void shorten(int times)
          Shortens this subgraph by randomly choosing and removing a MusicVertex and the edge(s) that connected it to the rest of this subgraph.
abstract  void slide(int times)
          Slides this Subgraph either left or right a number of times.
 java.lang.String toString()
          Returns a string with the toString's of all vertices and edges in this MusicGraph.
 
Methods inherited from class MusicGraph
boolMatrixEqual, boolMatrixMultiply, checkSorting, clone, contains, convertToScore, copyBoolMatrix, deepClone, equals, findVertexAt, getAllPossibleRightExtended, getAllPossibleRightSlides, getAllSequentialSubgraphsOfSize, getAllStrongSequentialSubgraphsOfSize, getBeginningSubgraphSet, getClosure, getMaxEndtime, getMaximalSequentialSubgraphSize, getMinStarttime, getNestedRestPercentage, getNestedVertexList, getNextGroup, getNSequentialSubgraphsOfSize, getStrongSinks, getStrongSources, getTransitiveClosure, graphicLayoutDone, graphIsConnected, hasInterpartEdges, hasMusedata, initGroupTokenizer, isSimpleGraph, maxUsage, nestedNumberOfRests, nestedNumOfCompoundVertices, nestedSize, nestingDepth, numOfCompoundVertices, overlap, prettyPrintBoolMatrix, printAllDist, size, sortEdges, sortVertexVectorByStarttime, sortVerticesByStarttime, testIntegrity, transitiveClosureOf, vertexAtIndexSplitsSubgraph
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mothergraph

protected MotherGraph mothergraph
The MotherGraph that owns the vertices and edges pointed to by this Subgraph.

Constructor Detail

Subgraph

public Subgraph()
Method Detail

isStrongSequential

public boolean isStrongSequential()
Returns true if this Subgraph is sequential with only strong FOLLOW edges. The method to check this: 1) this subgraph can have only one starting vertex. 2) all descendants(vertices) must have exactly one descendant, 3) except the last vertex, which must have exactly zero descendants.


toString

public java.lang.String toString()
Description copied from class: MusicGraph
Returns a string with the toString's of all vertices and edges in this MusicGraph.

Overrides:
toString in class MusicGraph

getLeftExtensibility

public abstract int getLeftExtensibility()
Returns how many times this Subgraph may be extended to the left.


getRightExtensibility

public abstract int getRightExtensibility()
Returns how many times this Subgraph may be extended to the right.


extend

public abstract void extend(int times)
                     throws java.lang.Exception
Extends this subgraph by randomly adding to it a MusicVertex which is connected to this subgraph in its mother graph. The edge connecting them is also added.

java.lang.Exception

shorten

public abstract void shorten(int times)
                      throws java.lang.Exception
Shortens this subgraph by randomly choosing and removing a MusicVertex and the edge(s) that connected it to the rest of this subgraph. Only vertices that do not split this graph may be removed.

java.lang.Exception

slide

public abstract void slide(int times)
                    throws java.lang.Exception
Slides this Subgraph either left or right a number of times.

java.lang.Exception

getAllSons

public java.util.Vector getAllSons(java.util.Vector vert)
Returns a Vector of MusicVertex which follow upon any of the music vertices in the input vector, i.e. there is a FOLLOWS MusicEdge from the vertex in the input vector to the one in the output vector.


getAllProperFollowInEdges

public java.util.Vector getAllProperFollowInEdges(boolean includeWeakEdges)
Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper follow in-edges of MusicVertex i in this Subgraph; proper follow in-edges are follow in-edges to the given vertex that are also contained in this Subgraph.

Specified by:
getAllProperFollowInEdges in class MusicGraph

getAllProperFollowOutEdges

public java.util.Vector getAllProperFollowOutEdges(boolean includeWeakEdges)
Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper follow out-edges of MusicVertex i in this Subgraph; proper follow out-edges are follow out-edges to the given vertex that are also contained in this Subgraph.

Specified by:
getAllProperFollowOutEdges in class MusicGraph

getAllProperInEdges

public java.util.Vector getAllProperInEdges(boolean includeWeakEdges)
Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper in-edges of MusicVertex i in this Subgraph; proper in-edges are in-edges to the given vertex that are also contained in this Subgraph.

Specified by:
getAllProperInEdges in class MusicGraph

getAllProperOutEdges

public java.util.Vector getAllProperOutEdges(boolean includeWeakEdges)
Returns a Vector of Vector of MusicEdge; the Vector of MusicEdges at index i in the returned Vector contains the proper out-edges of MusicVertex i in this Subgraph; proper out-edges are out-edges to the given vertex that are also contained in this Subgraph.

Specified by:
getAllProperOutEdges in class MusicGraph

getScore

public jm.music.data.Score getScore()
Returns the Score object that the MotherGraph of this Subgraph originated from.

Specified by:
getScore in class MusicGraph

getMotherGraph

public MotherGraph getMotherGraph()
Returns the MotherGraph of this Subgraph.

Specified by:
getMotherGraph in class MusicGraph

printTheScore

public void printTheScore(java.lang.String label)
For debugging. (converts this subgraph to a Score and writes it to a midi file)


getStrongFollowEdges

public java.util.Vector getStrongFollowEdges()
Returns a Vector of all strong FOLLOW edges in this Subgraph.


getFollowEdges

public java.util.Vector getFollowEdges()
Returns a Vector of all FOLLOW edges in this Subgraph.


getStrongSimultaneousEdges

public java.util.Vector getStrongSimultaneousEdges()
Returns a Vector of all strong SIMULTANEOUS edges in this Subgraph.


getSimultaneousEdges

public java.util.Vector getSimultaneousEdges()
Returns a Vector of all SIMULTANEOUS edges in this Subgraph.


getMothergraphCoverage

public abstract double getMothergraphCoverage()

numberOfLeftmostRests

public abstract int numberOfLeftmostRests()

numberOfRightmostRests

public abstract int numberOfRightmostRests()

removeVertexAndConnectedEdges

public void removeVertexAndConnectedEdges(MusicVertex mv)
Removes a given MusicVertex mv from this Subgraph along with any MusicEdges that connected mv to the rest of this Subgraph.


addVertexAndNecessaryEdges

public void addVertexAndNecessaryEdges(MusicVertex mv,
                                       MusicEdge me)
Adds a given MusicVertex mv and a MusicEdge me to this Subgraph along with any MusicEdges in the MotherGraph that connect mv to the rest of this Subgraph.


findEdgeConnectingToVertex

public MusicEdge findEdgeConnectingToVertex(MusicVertex mv)
If mv is outside this subgraph, and there is an edge e in the mothergraph connecting mv to some vertex in this subgraph, this method returns e, otherwise null.