本文整理汇总了C++中PNGraph::DelEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ PNGraph::DelEdge方法的具体用法?C++ PNGraph::DelEdge怎么用?C++ PNGraph::DelEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PNGraph
的用法示例。
在下文中一共展示了PNGraph::DelEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KeepAtMostOneChildPerNode
void TIncrementalClustering::KeepAtMostOneChildPerNode(PNGraph& G, TQuoteBase *QB, TDocBase *DB) {
TIntSet::TIter EndNode = AffectedNodes.EndI();
for (TIntSet::TIter NodeId = AffectedNodes.BegI(); NodeId < EndNode; NodeId++) {
TNGraph::TNodeI Node = G->GetNI(NodeId.GetKey());
TQuote SourceQuote;
if (QB->GetQuote(Node.GetId(), SourceQuote)) {
TInt NodeDegree = Node.GetOutDeg();
if (NodeDegree > 1) {
TFlt MaxScore = 0;
TInt MaxNodeId = 0;
TIntV NodeV;
// first pass: check to see if we are pointing to any old nodes - if so, they get higher
// priority over the new ones for edge selection.
bool ContainsOldNode = false;
for (int i = 0; i < NodeDegree; ++i) {
if (!NewQuotes.IsKey(Node.GetOutNId(i))) {
ContainsOldNode = true;
}
}
// modified edge selection: filter out new nodes if old ones exist.
for (int i = 0; i < NodeDegree; ++i) {
TInt CurNode = Node.GetOutNId(i);
NodeV.Add(CurNode);
TQuote DestQuote;
if (QB->GetQuote(CurNode, DestQuote)) {
TFlt EdgeScore = 0;
if (!ContainsOldNode || !NewQuotes.IsKey(Node.GetOutNId(i))) {
EdgeScore = ComputeEdgeScore(SourceQuote, DestQuote, DB);
}
if (EdgeScore > MaxScore) {
MaxScore = EdgeScore;
MaxNodeId = CurNode;
}
}
}
// remove all other edges, backwards to prevent indexing fail
for (int i = 0; i < NodeV.Len(); i++) {
if (NodeV[i] != MaxNodeId) {
G->DelEdge(Node.GetId(), NodeV[i]);
}
}
//printf("Out degree: %d out of %d\n", Node.GetOutDeg(), NodeDegree.Val);
}
}
}
fprintf(stderr, "finished deleting edges\n");
}
示例2: GetForest
/// returns a perfect binary tree minus one edge
PNGraph GetForest() {
PNGraph G = GetTree();
G->DelEdge(4,2);
return G;
}