本文整理汇总了C++中TNodeI::GetAdjacentModes方法的典型用法代码示例。如果您正苦于以下问题:C++ TNodeI::GetAdjacentModes方法的具体用法?C++ TNodeI::GetAdjacentModes怎么用?C++ TNodeI::GetAdjacentModes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNodeI
的用法示例。
在下文中一共展示了TNodeI::GetAdjacentModes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BFSTraversalOneHop
int TMultimodalGraphImplB::BFSTraversalOneHop(const TVec< TPair<TInt,TInt> >& StartingVertices) const {
int NumVerticesAndEdges = 0;
for (int i = 0; i < StartingVertices.Len(); i++) {
TNodeI NI = GetNI(StartingVertices.GetVal(i));
TIntV AdjacentModes = TIntV(); NI.GetAdjacentModes(AdjacentModes);
for (int ModeIdx = 0; ModeIdx < AdjacentModes.Len(); ModeIdx++) {
int ModeId = AdjacentModes.GetVal(ModeIdx);
for (int e = 0; e < NI.GetOutDeg(ModeId); e++) {
NumVerticesAndEdges += NI.GetOutNId(e, ModeId);
}
}
}
return NumVerticesAndEdges;
}
示例2: GetEI
TMultimodalGraphImplB::TEdgeI TMultimodalGraphImplB::GetEI(const TPair<TInt,TInt>& SrcNId, const TPair<TInt,TInt>& DstNId) const {
TNodeI CurNode = TNodeI(NodeToModeMapping.GetI(SrcNId.GetVal2()), &Graphs, &NodeToModeMapping);
TIntV AdjacentModes = TIntV();
CurNode.GetAdjacentModes(AdjacentModes);
TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(SrcNId.GetVal1(), DstNId.GetVal1());
int CurAdjacentMode = 0;
for (int i=0; i<AdjacentModes.Len();i++) {
if (AdjacentModes.GetDat(i) == DstNId.GetVal1()) {
CurAdjacentMode=i;
break;
}
}
return TEdgeI(CurNode, EndNI(), Graphs.GetDat(ModeIdsKey).GetEI(SrcNId.GetVal2(), DstNId.GetVal2()).GetCurEdge(), AdjacentModes, CurAdjacentMode);
}
示例3: RandomWalk
void TMultimodalGraphImplB::RandomWalk(TVec< TPair<TInt,TInt> > NodeIds, int WalkLength) {
int CurrentLocalNodeId = NodeToModeMapping.GetKey(NodeToModeMapping.GetRndKeyId(TInt::Rnd));
TPair<TInt,TInt> CurrentNodeId = TPair<TInt,TInt>(NodeToModeMapping.GetDat(CurrentLocalNodeId), CurrentLocalNodeId);
int NodeIdIdx = 0;
NodeIds.SetVal(NodeIdIdx++, CurrentNodeId);
while (NodeIds.Len() < WalkLength) {
TNodeI NI = GetNI(CurrentNodeId);
TIntV AdjacentModes = TIntV(); NI.GetAdjacentModes(AdjacentModes);
// Throw an appropriately biased coin here
int EdgeId = TInt::Rnd.GetUniDevInt(NI.GetOutDeg());
int i;
for (i = 0; i < AdjacentModes.Len(); i++) {
int ModeOutDeg = NI.GetOutDeg(AdjacentModes.GetDat(i));
if (EdgeId < ModeOutDeg) { break; }
EdgeId -= ModeOutDeg;
}
NodeIds.SetVal(NodeIdIdx++, TPair<TInt,TInt>(AdjacentModes.GetDat(i), NI.GetOutNId(EdgeId, AdjacentModes.GetDat(i))));
}
}
示例4: ConvertToImplC
PMultimodalGraphImplC TMultimodalGraphImplB::ConvertToImplC() const {
PMultimodalGraphImplC G = TMultimodalGraphImplC::New();
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
G->AddNode(TPair<TInt,TInt>(NI.GetModeId(), NI.GetId()));
}
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
int OutDeg = NI.GetOutDeg();
int InDeg = NI.GetInDeg();
G->ReserveInAndOutNIdV(TPair<TInt,TInt>(NI.GetModeId(), NI.GetId()), OutDeg, InDeg);
TVec<TInt> AdjacentModes = TVec<TInt>(); NI.GetAdjacentModes(AdjacentModes);
for (int i = 0; i < AdjacentModes.Len(); i++) {
int AdjacentMode = AdjacentModes.GetVal(i);
TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(NI.GetModeId(), AdjacentMode);
G->AddOutNIds(TPair<TInt,TInt>(NI.GetModeId(),NI.GetId()), Graphs.GetDat(ModeIdsKey).GetOutNId(NI.GetId()), AdjacentMode);
G->AddInNIds(TPair<TInt,TInt>(NI.GetModeId(),NI.GetId()), Graphs.GetDat(ModeIdsKey).GetInNId(NI.GetId()), AdjacentMode);
}
}
return G;
}