Created
May 23, 2017 21:05
-
-
Save holtgrewe/97aa92749b59eb1b3708d2e5f7314554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Term, TermMap, and directly related types --------------------------------- | |
public interface Prefix extends Serializable { | |
public ByteString getValue(); | |
} | |
public interface TermID extends Comparable <TermID>, Serializable { | |
public Prefix getPrefix(); | |
public int getID(); | |
} | |
public interface TermXRef extends Serializable { | |
public String getDatabase(); | |
public String getXrefID(); | |
public String getXrefName(); | |
} | |
public enum RelationQualifier { // WAS: TermRelaton | |
IS_A, | |
PART_OF_A, | |
REGULATES, | |
NEGATIVELY_REGULATES, | |
POSITIVELY_REGULATES, | |
UNKNOWN; | |
} | |
public interface TermRelation implements Serializable { // WAS: ParentTermID | |
public TermID getRelatedTermID(); | |
public RelationQualifier getRelationQualifier(); | |
} | |
public interface Term extends Serializble { | |
public TermID getID(); | |
public ByteString getName(); | |
public Namespace getNamespace(); | |
public TermRelation[] getRelations(); // WAS: getParentRelations() | |
public boolean isObsolete(); | |
public ByteString getDefinition(); | |
public TermID[] getEquivalents(); | |
public Subset[] getSubsets(); | |
public ByteString[] getSynonyms(); | |
public TermXref[] getXrefs(); | |
} | |
public interface TermMap extends Iterable<Term>, Serializable { | |
public Term get(TermID termID); | |
public int size(); | |
public int maxTermID(); | |
} | |
// Graph --------------------------------------------------------------------- | |
public interface Edge<V> extends Serializable { | |
public V getSource(); | |
public V getDest(); | |
} | |
public interface MutableEdge<V> extends Edge<V> { | |
public V setSource(V s); | |
public V setDest(V t); | |
} | |
/** Iterate edges, vertices and immediate neighbors only | |
*/ | |
public interface DirectedGraph<V, E> extends Serializable { | |
public boolean containsVertex(V v); | |
public int countVertices(); | |
public Collection<V> getVertices(); | |
public Iterator<V> vertexIterator(); | |
public int countEdges(); | |
public boolean containsEdgeBetween(V s, V t); | |
public Collection<E> getEdges(); | |
public Iterator<E> edgeIterator(); | |
public E getEdge(V s, V t); | |
public int inDegree(V v); | |
public Iterator<E> inEdgeIterator(V v); | |
public Iterator<V> viaInEdgeIterator(V v); // was parentVertexIterator | |
public int outDegree(V v); | |
public Iterator<E> outEdgeIterator(V v); | |
public Iterator<V> viaOutEdgeIterator(V v); // was childVertexIterator | |
public DirectedGraph<V, E> subGraph(Collection<V> vertices); | |
} | |
// TODO: MutableDirectedGraph | |
/** More complex queries related to paths, precomputation improves performance | |
*/ | |
public interface NavigableDirectedGraphDecorator<V, E> | |
extends DirectedGraph<V, E>, Serializable { | |
public boolean forwardPathExists(V u, V v); // following s-t arcs from s to t | |
public boolean reversePathExists(V u, V v); // following s-t arcs from t to s | |
public Collection<V> forwardPathReachable(V v); // follow s-t arcs from s to t, WAS: getAncestors | |
public Collection<V> reversePathReachable(V v); // follow s-t arcs from t to s, WAS: getChildren | |
} | |
// Ontology ------------------------------------------------------------------ | |
public interface OntologyEdge extends Edge<TermID> { | |
public RelationQualifier getQualifier(); | |
} | |
public interface MutableOntologyEdge extends OntologyEdge, MutableEdge<TermID> { | |
public void setRelationQualifier(RelationQualifier rq); | |
} | |
/** Adds requirement for one single root and definition that children point to their | |
* parents (e.g., for definition of siblings). | |
*/ | |
public interface Ontology extends DirectedGraph<TermID, OntologyEdge>, Serializable { | |
public TermID getRoot(); | |
} | |
public interface MutableOntology extends Ontology { | |
public void setRoot(TermID t); | |
} | |
public interface NavigableOntology extends Ontology { | |
public Collection<V> getSiblings(V v); | |
} | |
// Graph Algorithms in their own classes ------------------------------------- | |
public interface VertexVisitor<V, E> { | |
public void visit(DirectedGraph<V, E> g, V v); | |
} | |
public class BreadthFirstSearch<V, E> { | |
public void startFromForward(DirectedGraph<V, E> g, V v, VertexVisitor<V, E> visitor); | |
public void startFromReverse(DirectedGraph<V, E> g, V v, VertexVisitor<V, E> visitor); | |
} | |
public class DepthFirstSearch<V, E> { | |
public void startFromForward(DirectedGraph<V, E> g, V v, VertexVisitor<V, E> visitor); | |
public void startFromReverse(DirectedGraph<V, E> g, V v, VertexVisitor<V, E> visitor); | |
} | |
public class TopologicalSorting<V, E> { | |
public void startForward(DirectedGraph<V, E> g, VertexVisitor<V, E> visitor); | |
public void startReverse(DirectedGraph<V, E> g, VertexVisitor<V, E> visitor); | |
} | |
// Ontology Algorithms in their own classes ---------------------------------- | |
/** Walk edges in Ontology forward/to root | |
*/ | |
public class ForwardWalker { | |
public void start(Ontology o, TermID t, VertexVisitor<TermID, OntologyEdge> visitor); | |
} | |
/** Walk edges in Ontology reverse/to leafs | |
*/ | |
public class ReverseWalker { | |
public void start(Ontology o, TermID t, VertexVisitor<TermID, OntologyEdge> visitor); | |
} | |
/** Compute shared parents/children of two vertices | |
*/ | |
public class SharedNeighborsWalker { | |
public Collection<TermID> viaForward(Ontology o, TermID a, TermID b); | |
public Collection<TermID> viaReverse(Ontology o, TermID a, TermID b); | |
} | |
/** Compute shared on path to root/leafs | |
*/ | |
public class SharedPathWalker { | |
public Collection<TermID> viaForwardTowardsRoot(Ontology o, TermID a, TermID b); | |
public Collection<TermID> viaReverseTowardsLeafs(Ontology o, TermID a, TermID b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment