コード例 #1
0
void C_DirectedGraph::addNode (const uint32_t inNodeIndex) {
  mNodes.add (inNodeIndex) ;
  while (((int32_t) inNodeIndex) >= mEdges.count ()) {
    mEdges.appendObject (C_UIntSet ()) ;
    mReverseEdges.appendObject (C_UIntSet ()) ;
  }
  #ifndef DO_NOT_GENERATE_CHECKINGS
    checkGraph (HERE) ;
  #endif
}
コード例 #2
0
void C_DirectedGraph::addEdge (const uint32_t inSourceNodeIndex,
                              const uint32_t inTargetNodeIndex) {
  addNode (inSourceNodeIndex) ;
  addNode (inTargetNodeIndex) ;
  mEdges ((int32_t) inSourceNodeIndex COMMA_HERE).add (inTargetNodeIndex) ;
  mReverseEdges ((int32_t) inTargetNodeIndex COMMA_HERE).add (inSourceNodeIndex) ;
  #ifndef DO_NOT_GENERATE_CHECKINGS
    checkGraph (HERE) ;
  #endif
}
コード例 #3
0
void C_DirectedGraph::addNodes (const C_UIntSet inNodes) {
  mNodes |= inNodes ;
  const uint32_t lastPlusOne = mNodes.firstValueNotIsSet () ;
  while (lastPlusOne > (uint32_t) mEdges.count ()) {
    mEdges.appendObject (C_UIntSet ()) ;
    mReverseEdges.appendObject (C_UIntSet ()) ;
  }
  #ifndef DO_NOT_GENERATE_CHECKINGS
    checkGraph (HERE) ;
  #endif
}
コード例 #4
0
void C_DirectedGraph::removeEdgesToNode (const uint32_t inNodeIndex
                                         COMMA_LOCATION_ARGS) {
//--- get nodes that have edges to this node
  const C_UIntSet nodeSet = mReverseEdges ((int32_t) inNodeIndex COMMA_THERE) ;
//--- Remove edges in reverse egde array
  mReverseEdges.setObjectAtIndex (C_UIntSet (), (int32_t) inNodeIndex COMMA_THERE) ;
//--- Remove edge in direct edge array
  TC_UniqueArray <uint32_t> sourceNodeArray ; nodeSet.getValueArray (sourceNodeArray) ;
  for (int32_t i=0 ; i<sourceNodeArray.count () ; i++) {
    const uint32_t sourceNodeIndex = sourceNodeArray (i COMMA_HERE) ;
    mEdges ((int32_t) sourceNodeIndex COMMA_HERE).remove (inNodeIndex) ;
  }
//--- Check
  #ifndef DO_NOT_GENERATE_CHECKINGS
    checkGraph (HERE) ;
  #endif
}
コード例 #5
0
ファイル: PhyEngine.cpp プロジェクト: Armanfarhang/iris_core
    std::vector< boost::shared_ptr< DataBufferBase > >
    PhyEngine::loadEngine(EngineDescription eng,
                          std::vector< boost::shared_ptr< DataBufferBase > > inputLinks)
    {
        //Set the external input buffer
        engInputBuffers_ = inputLinks;

        //Set the engineGraph
        engineGraph_ = eng.engineGraph;

        //Check the graph
        checkGraph(engineGraph_);

        //Build the engine
        buildEngineGraph(engineGraph_);

        return engOutputBuffers_;
    }
コード例 #6
0
void C_DirectedGraph::removeNode (const uint32_t inNodeIndex) {
  if (inNodeIndex < (uint32_t) mEdges.count ()) {
    mNodes.remove (inNodeIndex) ;
    const C_UIntSet targetSet = mEdges ((int32_t) inNodeIndex COMMA_HERE) ;
    TC_UniqueArray <uint32_t> targetList ; targetSet.getValueArray (targetList) ;
    for (int32_t i=0 ; i<targetList.count () ; i++) {
      const uint32_t targetIndex = targetList (i COMMA_HERE) ;
      mReverseEdges ((int32_t) targetIndex COMMA_HERE).remove (inNodeIndex) ;
    }
    mEdges.setObjectAtIndex (C_UIntSet (), (int32_t) inNodeIndex COMMA_HERE) ;
  }
  const uint32_t f = mNodes.firstValueNotIsSet () ;
  while (f < (uint32_t) mEdges.count ()) {
    mEdges.removeLastObject (HERE) ;
    mReverseEdges.removeLastObject (HERE) ;
  }
  #ifndef DO_NOT_GENERATE_CHECKINGS
    checkGraph (HERE) ;
  #endif
}