amnh / PCG

𝙋𝙝𝙮𝙡𝙤𝙜𝙚𝙣𝙚𝙩𝙞𝙘 𝘾𝙤𝙢𝙥𝙤𝙣𝙚𝙣𝙩 𝙂𝙧𝙖𝙥𝙝 ⸺ Haskell program and libraries for general phylogenetic graph search
28 stars 1 forks source link

Create a better interface for the "graph object" #14

Open recursion-ninja opened 7 years ago

recursion-ninja commented 7 years ago

Issue by recursion-ninja Monday Mar 27, 2017 at 18:40 GMT Originally opened as https://github.com/ima-hima/PCG/issues/14


We should probably have separate interfaces for manipulating the "data matrix" of the graph and the topology of the graph. Should probably be designed by committee to elicit API requirements and then refactored in secret to actually work and be beautiful.

recursion-ninja commented 6 years ago

Graph operations:

recursion-ninja commented 6 years ago

Note that is if the leaf nodes are placed at vector indices [0, n-1] then we can reused the BitVector representations of the leafset of a sub tree between graph rearrangements without worrying about the BitVector indices falling out of sync with the rest of the data structure.

Boarders commented 6 years ago

One initial idea for an interface using associated types is something like:


class DAGGraph g n where
  type Node g      :: *
  type Edge g      :: *
  type DAGForest g  :: *
  type EdgeData g   :: *

  getLeafSet       :: g -> NonEmpty (Node g)
  getRootSet       :: g -> NonEmpty (Node g)
  getNodeSet       :: g -> NonEmpty (Node g)
  getEdgeSet       :: g -> NonEmpty (Edge g)
  getChildren      :: g -> Node g -> [Node g]
  getParents       :: g -> Node g -> [Node g]
  getIncidentEdges :: g -> Node g -> [Edge g]
  getNodeData      :: Node g -> g -> n
  getEdgeData      :: Edge g -> g -> EdgeData g
  getColumn        :: g -> Word -> Vector (Block (EdgeData g) n)
  getBlockSummary  :: g -> CharSeq (Block (EdgeData g) n)

  removeEdge :: Edge g -> DAGForest g -> DAGForest g
  joinGraphObjects
    :: Either (Node g) (Edge g)
    -> Either (Node g) (Edge g)
    -> DAGForest g
    -> DAGForest g

  postorderTraversal :: (n -> n') -> g -> DAGGraph (EdgeData g) n'
  preorderTraversal  :: (n -> n') -> g -> DAGGraph (EdgeData g) n'

I'm not sure how that fits with the above ideas in terms of indexing or using type families so I don't know how useful it is as a starting point.