Class MusicGraph

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

public abstract class MusicGraph
extends java.lang.Object

MusicGraph is the abstract superclass of MotherGraph and Subgraph. This class contains the fundamental attributes (vertices and edges) of a graph and a number of general methods to manipulate a graph.


Field Summary
 java.util.Vector edges
          A Vector of MusicEdge.
 java.lang.String title
          The title is just a name (a label) that makes it easier for the user to distinguish between MusicGraphs.
 java.util.Vector vertices
          A Vector of MusicVertex.
 
Constructor Summary
MusicGraph()
           
 
Method Summary
static boolean boolMatrixEqual(boolean[][] m1, boolean[][] m2)
          Helper function.
static boolean[][] boolMatrixMultiply(boolean[][] m1, boolean[][] m2)
          Helper function.
 void checkSorting()
          For debugging.
abstract  java.lang.Object clone()
           
 boolean contains(MusicGraph other)
          Checks if all vertices and all edges in the other MusicGraph are also contained in this MusicGraph.
abstract  jm.music.data.Score convertToScore()
          ConvertToScore returns a Score representing the music in this MusicGraph.
static boolean[][] copyBoolMatrix(boolean[][] m)
          Helper function.
 MotherGraph deepClone()
          A deep clone not only makes a clone of the 'vertices' and 'edges' Vectors of references to MusicVertex and MusicEdge objects but also clones these objects; the resulting graph thus points to objects that are not owned by any other graphs and thus must be a MotherGraph.
 boolean equals(MusicGraph other)
          If this MusicGraph contains() the other MusicGraph, and the other MusicGraph contains() this MusicGraph, true is returned, otherwise false.
 MusicVertex findVertexAt(java.awt.Point p)
          Searches for a vertex based on its graphic layout - if it clips p, it is returned.
 java.util.Vector getAllPossibleRightExtended(java.util.Vector subs)
          Gives a Vector of SeqSubgraph which are all the possible right extensions of the SeqSubgraphs in the input Vector; considers only right extensions possible inside this graph whether its a subgraph or not.
 java.util.Vector getAllPossibleRightSlides(java.util.Vector subs)
          Gives a Vector of SeqSubgraph which are all the possible right slides of the SeqSubgraphs in the input Vector; Considers only right slides possible inside this graph whether its a subgraph or not.
abstract  java.util.Vector getAllProperFollowInEdges(boolean includeWeakEdges)
           
abstract  java.util.Vector getAllProperFollowOutEdges(boolean includeWeakEdges)
           
abstract  java.util.Vector getAllProperInEdges(boolean includeWeakEdges)
           
abstract  java.util.Vector getAllProperOutEdges(boolean includeWeakEdges)
           
 java.util.Vector getAllSequentialSubgraphsOfSize(int size)
          Like getAllSequentialSubgraphsOfSize(int size), but includes weak FOLLOW edges.
 java.util.Vector getAllStrongSequentialSubgraphsOfSize(int size)
          Returns a Vector of SeqSubgraph.
 java.util.Vector getBeginningSubgraphSet(int size)
          Gives a Vector of SeqSubgraph which are all the possible sequential subgraphs of a given length (size) whose first MusicVertex is one of the first vertices in this MusicGraph.
 boolean[][] getClosure(boolean includeSimEdges, boolean includeWeakEdges)
          Constructs an incidence matrix describing which vertices are connected to which other vertices.
 double getMaxEndtime()
          Returns the greatest end time found in the 'vertices' Vector.
abstract  int getMaximalSequentialSubgraphSize()
           
 double getMinStarttime()
          Returns the least start time found in the 'vertices' Vector.
abstract  MotherGraph getMotherGraph()
           
 double getNestedRestPercentage()
          Returns the nestedNumberOfRests divided by the nestedSize.
 java.util.Vector getNestedVertexList()
          Returns a vector of SimpleVertex's all contained in this musicgraph or inside CompoundVertex's inside it.
 java.util.Vector getNextGroup()
          This method is the heart of the group tokenizer built into the MusicGraph class; it finds and returns a Vector of MusicVertex. initGroupTokenizer() must have been called before using this method.
 java.util.Vector getNSequentialSubgraphsOfSize(int n, int size)
          Returns a Vector of at least n sequential subgraphs of size 'size'.
abstract  jm.music.data.Score getScore()
          GetScore returns a pointer to the original Score that this MusicGraph's mothergraph was created from.
 java.util.Vector getStrongSinks()
          Returns a Vector of all MusicVertices that have no outEdges of type FOLLOWS
 java.util.Vector getStrongSources()
          Returns a Vector of all MusicVertices that have no inEdges of type FOLLOWS.
 boolean[][] getTransitiveClosure(boolean includeSimEdges, boolean includeWeakEdges)
          Constructs a matrix describing which vertices can be reached from which other vertices.
 boolean graphicLayoutDone()
          A method used in connection with the GUI part of the SimFinder system; it returns true if all vertices and all edges have been assigned a position in the graphical layout.
 boolean graphIsConnected(boolean includeSimEdges, boolean includeWeakEdges)
          Determines whether this graph is connected, with or without SIMULTANEOUS, WEAKFOLLOWS and WEAKSIMULTANEOUS edges, according to the parameters.
 boolean hasInterpartEdges()
          Returns true if there are any edges in this graph that connect two vertices belonging to different Parts; if there are, this is a non-partwise graph, otherwise it is a partwise graph.
 boolean hasMusedata()
          Returns true if there is information originating from a MuseData file in any vertices in this graph; in particular, pitch spelling.
 boolean initGroupTokenizer(double d)
          The group tokenizer is a mechanism built into this class which allows us to group nodes that are simultaneous (d=0.0) or within some distance d.
 boolean isSimpleGraph()
          Returns true if there are no CompoundVertex in this graph.
 int maxUsage()
          Returns the maximal value of the usage counter in every vertex in this MusicGraph.
 int nestedNumberOfRests()
          Returns the number of vertices in this MusicGraph that represent a rest, plus the nestedNumberOfRests of the subgraphs inside any CompoundVertex's in this MusicGraph.
 int nestedNumOfCompoundVertices()
          The nested version of numOfCompoundVertices().
 int nestedSize()
          Recursive definition: Returns the number of vertices in this graph plus the nested size of any compound vertices contained in this graph.
 int nestingDepth()
          Returns how deep a tree we may descend into if we look inside the compound vertices contained in this graph; in other words, how many compound vertices are contained inside each other in this graph.
 int numOfCompoundVertices()
          Returns the number of CompoundVertex in this graph.
 int overlap(MusicGraph other)
          Returns the sum of the number of vertices and the number of edges that this MusicGraph has in common with the other; this is mostly useful for comparing Subgraphs.
static void prettyPrintBoolMatrix(boolean[][] b)
          For debugging.
 void printAllDist()
          For debugging.
 int size()
          Returns the number of simple or compound vertices in this graph; see also method nestedSize().
 void sortEdges()
          Deprecated. Not used any more. Use sortVerticesByStarttime() instead.
 void sortVertexVectorByStarttime(java.util.Vector vert)
          Sorts the input Vector of MusicVertex by start time.
 void sortVerticesByStarttime()
          A helper function that calls the sortVertexVectorByStarttime() with the 'vertices' Vector as a parameter.
 int testIntegrity()
          For debugging.
 java.lang.String toString()
          Returns a string with the toString's of all vertices and edges in this MusicGraph.
static boolean[][] transitiveClosureOf(boolean[][] res)
          Helper function.
 boolean vertexAtIndexSplitsSubgraph(int index, boolean[][] originalClosure)
          Uses the transitive closure of the graph to determine if removing the vertex at the specified index in the "vertices" Vector would split this MusicGraph into two unconnected halves.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vertices

public java.util.Vector vertices
A Vector of MusicVertex.


edges

public java.util.Vector edges
A Vector of MusicEdge.


title

public java.lang.String title
The title is just a name (a label) that makes it easier for the user to distinguish between MusicGraphs.

Constructor Detail

MusicGraph

public MusicGraph()
Method Detail

size

public int size()
Returns the number of simple or compound vertices in this graph; see also method nestedSize().


nestedSize

public int nestedSize()
Recursive definition: Returns the number of vertices in this graph plus the nested size of any compound vertices contained in this graph. It thus returns the number of SimpleVertex contained in this MusicGraph and all of its inner CompoundVertex's.


getStrongSources

public java.util.Vector getStrongSources()
Returns a Vector of all MusicVertices that have no inEdges of type FOLLOWS.


getStrongSinks

public java.util.Vector getStrongSinks()
Returns a Vector of all MusicVertices that have no outEdges of type FOLLOWS


checkSorting

public void checkSorting()
For debugging.


initGroupTokenizer

public boolean initGroupTokenizer(double d)
The group tokenizer is a mechanism built into this class which allows us to group nodes that are simultaneous (d=0.0) or within some distance d. Groups are found and returned by the getNextGroup() method, but some variables need to be initialized first. That initialization is accomplished by this method.


getNextGroup

public java.util.Vector getNextGroup()
This method is the heart of the group tokenizer built into the MusicGraph class; it finds and returns a Vector of MusicVertex. initGroupTokenizer() must have been called before using this method. Returns a Vector of size=0 when no more vertices in graph.


vertexAtIndexSplitsSubgraph

public boolean vertexAtIndexSplitsSubgraph(int index,
                                           boolean[][] originalClosure)
Uses the transitive closure of the graph to determine if removing the vertex at the specified index in the "vertices" Vector would split this MusicGraph into two unconnected halves.


toString

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

Overrides:
toString in class java.lang.Object

equals

public boolean equals(MusicGraph other)
If this MusicGraph contains() the other MusicGraph, and the other MusicGraph contains() this MusicGraph, true is returned, otherwise false.


contains

public boolean contains(MusicGraph other)
Checks if all vertices and all edges in the other MusicGraph are also contained in this MusicGraph.


overlap

public int overlap(MusicGraph other)
Returns the sum of the number of vertices and the number of edges that this MusicGraph has in common with the other; this is mostly useful for comparing Subgraphs. "Having in common" means that both MusicGraphs are pointing to the same MusicVertex or MusicEdge objects. A MusicVertex or MusicEdge object is always owned by some MotherGraph.


sortVerticesByStarttime

public void sortVerticesByStarttime()
A helper function that calls the sortVertexVectorByStarttime() with the 'vertices' Vector as a parameter.


sortVertexVectorByStarttime

public void sortVertexVectorByStarttime(java.util.Vector vert)
Sorts the input Vector of MusicVertex by start time.


sortEdges

public void sortEdges()
Deprecated. Not used any more. Use sortVerticesByStarttime() instead.


clone

public abstract java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getAllStrongSequentialSubgraphsOfSize

public java.util.Vector getAllStrongSequentialSubgraphsOfSize(int size)
Returns a Vector of SeqSubgraph. CAREFUL!! The complexity of this method easily exceeds anything computable in realistic time! Consider using its little brother, getNSequentialSubgraphsOfSize() instead.


getAllSequentialSubgraphsOfSize

public java.util.Vector getAllSequentialSubgraphsOfSize(int size)
Like getAllSequentialSubgraphsOfSize(int size), but includes weak FOLLOW edges.


getNSequentialSubgraphsOfSize

public java.util.Vector getNSequentialSubgraphsOfSize(int n,
                                                      int size)
Returns a Vector of at least n sequential subgraphs of size 'size'.


getMotherGraph

public abstract MotherGraph getMotherGraph()

getMaximalSequentialSubgraphSize

public abstract int getMaximalSequentialSubgraphSize()

getBeginningSubgraphSet

public java.util.Vector getBeginningSubgraphSet(int size)
Gives a Vector of SeqSubgraph which are all the possible sequential subgraphs of a given length (size) whose first MusicVertex is one of the first vertices in this MusicGraph.


getAllPossibleRightExtended

public java.util.Vector getAllPossibleRightExtended(java.util.Vector subs)
Gives a Vector of SeqSubgraph which are all the possible right extensions of the SeqSubgraphs in the input Vector; considers only right extensions possible inside this graph whether its a subgraph or not.


getAllPossibleRightSlides

public java.util.Vector getAllPossibleRightSlides(java.util.Vector subs)
Gives a Vector of SeqSubgraph which are all the possible right slides of the SeqSubgraphs in the input Vector; Considers only right slides possible inside this graph whether its a subgraph or not.


getAllProperFollowInEdges

public abstract java.util.Vector getAllProperFollowInEdges(boolean includeWeakEdges)

getAllProperFollowOutEdges

public abstract java.util.Vector getAllProperFollowOutEdges(boolean includeWeakEdges)

getAllProperInEdges

public abstract java.util.Vector getAllProperInEdges(boolean includeWeakEdges)

getAllProperOutEdges

public abstract java.util.Vector getAllProperOutEdges(boolean includeWeakEdges)

graphIsConnected

public boolean graphIsConnected(boolean includeSimEdges,
                                boolean includeWeakEdges)
Determines whether this graph is connected, with or without SIMULTANEOUS, WEAKFOLLOWS and WEAKSIMULTANEOUS edges, according to the parameters.


getClosure

public boolean[][] getClosure(boolean includeSimEdges,
                              boolean includeWeakEdges)
Constructs an incidence matrix describing which vertices are connected to which other vertices.


getTransitiveClosure

public boolean[][] getTransitiveClosure(boolean includeSimEdges,
                                        boolean includeWeakEdges)
Constructs a matrix describing which vertices can be reached from which other vertices.


transitiveClosureOf

public static boolean[][] transitiveClosureOf(boolean[][] res)
Helper function.


copyBoolMatrix

public static boolean[][] copyBoolMatrix(boolean[][] m)
Helper function.


boolMatrixEqual

public static boolean boolMatrixEqual(boolean[][] m1,
                                      boolean[][] m2)
Helper function.


boolMatrixMultiply

public static boolean[][] boolMatrixMultiply(boolean[][] m1,
                                             boolean[][] m2)
Helper function.


prettyPrintBoolMatrix

public static void prettyPrintBoolMatrix(boolean[][] b)
For debugging.


getScore

public abstract jm.music.data.Score getScore()
GetScore returns a pointer to the original Score that this MusicGraph's mothergraph was created from.


convertToScore

public abstract jm.music.data.Score convertToScore()
ConvertToScore returns a Score representing the music in this MusicGraph. For subgraphs, it is a newly instantiated and built Score, for MotherGraphs it is a pointer to the original Score and thus returns the same as getScore().


getNestedRestPercentage

public double getNestedRestPercentage()
Returns the nestedNumberOfRests divided by the nestedSize.


nestedNumberOfRests

public int nestedNumberOfRests()
Returns the number of vertices in this MusicGraph that represent a rest, plus the nestedNumberOfRests of the subgraphs inside any CompoundVertex's in this MusicGraph.


maxUsage

public int maxUsage()
Returns the maximal value of the usage counter in every vertex in this MusicGraph.


getMinStarttime

public double getMinStarttime()
Returns the least start time found in the 'vertices' Vector.


getMaxEndtime

public double getMaxEndtime()
Returns the greatest end time found in the 'vertices' Vector.


isSimpleGraph

public boolean isSimpleGraph()
Returns true if there are no CompoundVertex in this graph.


numOfCompoundVertices

public int numOfCompoundVertices()
Returns the number of CompoundVertex in this graph.


nestedNumOfCompoundVertices

public int nestedNumOfCompoundVertices()
The nested version of numOfCompoundVertices().


nestingDepth

public int nestingDepth()
Returns how deep a tree we may descend into if we look inside the compound vertices contained in this graph; in other words, how many compound vertices are contained inside each other in this graph.


getNestedVertexList

public java.util.Vector getNestedVertexList()
Returns a vector of SimpleVertex's all contained in this musicgraph or inside CompoundVertex's inside it. This in effect is a flattening of the hierarchical structure, but without edges.


hasInterpartEdges

public boolean hasInterpartEdges()
Returns true if there are any edges in this graph that connect two vertices belonging to different Parts; if there are, this is a non-partwise graph, otherwise it is a partwise graph.


hasMusedata

public boolean hasMusedata()
Returns true if there is information originating from a MuseData file in any vertices in this graph; in particular, pitch spelling.


deepClone

public MotherGraph deepClone()
A deep clone not only makes a clone of the 'vertices' and 'edges' Vectors of references to MusicVertex and MusicEdge objects but also clones these objects; the resulting graph thus points to objects that are not owned by any other graphs and thus must be a MotherGraph.


graphicLayoutDone

public boolean graphicLayoutDone()
A method used in connection with the GUI part of the SimFinder system; it returns true if all vertices and all edges have been assigned a position in the graphical layout.


findVertexAt

public MusicVertex findVertexAt(java.awt.Point p)
Searches for a vertex based on its graphic layout - if it clips p, it is returned.


testIntegrity

public int testIntegrity()
For debugging.


printAllDist

public void printAllDist()
For debugging.