def g3 = ArrayBasedDirectedGraph()

in cassovary-core/src/main/scala/com/twitter/cassovary/graph/TestGraph.scala [81:185]


  def g3 = ArrayBasedDirectedGraph(Seq(
    NodeIdEdgesMaxId(10, Array(11, 12)),
    NodeIdEdgesMaxId(11, Array(12)),
    NodeIdEdgesMaxId(12, Array(11))
    ), StoredGraphDir.BothInOut, NeighborsSortingStrategy.LeaveUnsorted)

  def g5 = ArrayBasedDirectedGraph(Seq(
    NodeIdEdgesMaxId(10, Array(11, 12, 13)),
    NodeIdEdgesMaxId(11, Array(12)),
    NodeIdEdgesMaxId(12, Array(11)),
    NodeIdEdgesMaxId(13, Array(14)),
    NodeIdEdgesMaxId(14, Array())
    ), StoredGraphDir.BothInOut, NeighborsSortingStrategy.LeaveUnsorted)

  def dangling_g7 = ArrayBasedDirectedGraph(Seq(
    NodeIdEdgesMaxId(1, Array(2)),
    NodeIdEdgesMaxId(2, Array(3, 4)),
    NodeIdEdgesMaxId(3, Array()),
    NodeIdEdgesMaxId(4, Array()),
    NodeIdEdgesMaxId(5, Array(6)),
    NodeIdEdgesMaxId(6, Array(1, 2, 7)),
    NodeIdEdgesMaxId(7, Array())
  ), StoredGraphDir.OnlyOut, NeighborsSortingStrategy.LeaveUnsorted)

  def dangling_g7_in = ArrayBasedDirectedGraph(Seq(
    NodeIdEdgesMaxId(1, Array(2)),
    NodeIdEdgesMaxId(2, Array(3, 4)),
    NodeIdEdgesMaxId(3, Array()),
    NodeIdEdgesMaxId(4, Array()),
    NodeIdEdgesMaxId(5, Array(6)),
    NodeIdEdgesMaxId(6, Array(1, 2, 7)),
    NodeIdEdgesMaxId(7, Array())
  ), StoredGraphDir.OnlyIn, NeighborsSortingStrategy.LeaveUnsorted)

  val nodeSeqIterator = Seq(
      NodeIdEdgesMaxId(10, Array(11, 12, 13)),
      NodeIdEdgesMaxId(11, Array(12, 14)),
      NodeIdEdgesMaxId(12, Array(14)),
      NodeIdEdgesMaxId(13, Array(12, 14)),
      NodeIdEdgesMaxId(14, Array(15)),
      NodeIdEdgesMaxId(15, Array(10, 11))
      )

  val nodeSeqIteratorWithEmpty = Seq(
    NodeIdEdgesMaxId(0, Array.empty[Int]),
    NodeIdEdgesMaxId(1, Array.empty[Int])
  ) ++ nodeSeqIterator

  // using testGraph becomes onerous for non-trivial graphs
  def g6 = ArrayBasedDirectedGraph(nodeSeqIterator, StoredGraphDir.BothInOut,
    NeighborsSortingStrategy.LeaveUnsorted)
  def g6_onlyout = ArrayBasedDirectedGraph(nodeSeqIterator, StoredGraphDir.OnlyOut,
    NeighborsSortingStrategy.LeaveUnsorted)
  def g6_onlyin = ArrayBasedDirectedGraph(nodeSeqIterator, StoredGraphDir.OnlyIn,
    NeighborsSortingStrategy.LeaveUnsorted)

  def g6WithEmptyNodes = ArrayBasedDirectedGraph(nodeSeqIteratorWithEmpty, StoredGraphDir.BothInOut,
    NeighborsSortingStrategy.LeaveUnsorted)

  val nodeSeqIterator2 = Seq(
      NodeIdEdgesMaxId(10, Array(11, 12, 13)),
      NodeIdEdgesMaxId(11, Array(10, 13, 14)),
      NodeIdEdgesMaxId(12, Array(13, 14)),
      NodeIdEdgesMaxId(13, Array(12, 14)),
      NodeIdEdgesMaxId(14, Array(10, 11, 15)),
      NodeIdEdgesMaxId(15, Array(10, 11, 16)),
      NodeIdEdgesMaxId(16, Array(15))
      )
  def g7_onlyout = ArrayBasedDirectedGraph(nodeSeqIterator2, StoredGraphDir.OnlyOut,
    NeighborsSortingStrategy.LeaveUnsorted)
  def g7_onlyin = ArrayBasedDirectedGraph(nodeSeqIterator2, StoredGraphDir.OnlyIn,
    NeighborsSortingStrategy.LeaveUnsorted)

  // Bipartite Graph
  def bipartiteGraphSingleSide = {
    /*
   lN -> 1 to 5
   rN -> 4,8,5,10,123,0
   1 --> i:(), o:()
   2 --> i: (), o: (5,10)
   3 --> i: (), o: ()
   4 --> i: (), o: (14)
   5 --> i: (), o: (5,10,8)
   */

    val leftNodes = new Array[BipartiteNode](6)
    leftNodes(1) = new LeftNode(1, CSeq.empty[Int], CSeq.empty[Int])
    leftNodes(2) = new LeftNode(2, CSeq.empty[Int], CSeq(Array(5, 10)))
    leftNodes(3) = new LeftNode(3, CSeq.empty[Int], CSeq.empty[Int])
    leftNodes(4) = new LeftNode(4, CSeq.empty[Int], CSeq(Array(14)))
    leftNodes(5) = new LeftNode(5, CSeq.empty[Int], CSeq(Array(5, 10, 8)))

    val rightNodes = new Array[BipartiteNode](124)
    rightNodes(14) = new RightNode(14, CSeq(Array(4)), CSeq.empty[Int])
    rightNodes(4) = new RightNode(4, CSeq.empty[Int], CSeq.empty[Int])
    rightNodes(5) = new RightNode(5, CSeq(Array(2, 5)), CSeq.empty[Int])
    rightNodes(8) = new RightNode(8, CSeq(Array(5)), CSeq.empty[Int])
    rightNodes(10) = new RightNode(10, CSeq(Array(2, 5)), CSeq.empty[Int])
    rightNodes(123) = new RightNode(123, CSeq.empty[Int], CSeq.empty[Int])

    val leftSide = BipartiteSide(leftNodes, 5, 6)
    val rightSide = BipartiteSide(rightNodes, 6, 0)

    new BipartiteGraph(leftSide, rightSide, BipartiteGraphDir.LeftToRight, false)
  }