コード例 #1
0
ファイル: test-triad.cpp プロジェクト: Antobiotics/snap
// Test GetNodeTriads (GroupSet, InGroupEdges, InOutGroupEdges, OutGroupEdges)
TEST(triad, TestGetNodeTriadsGroupSetAndOut) {
  // Test TUNGraph
  PUNGraph GraphTUN = TriadGetTestTUNGraph();
  for (int i = 0; i < GraphTUN->GetNodes(); i++) {
    TIntSet GroupSet;
    GetGroupSet(i, GroupSet);
    int InGroupEdges = -1, InOutGroupEdges = -1, OutGroupEdges = -1;
    TSnap::GetNodeTriads(GraphTUN, i, GroupSet, 
                         InGroupEdges, InOutGroupEdges, OutGroupEdges);
    VerifyInGroupEdges(i, InGroupEdges);
    VerifyInOutGroupEdges(i, InOutGroupEdges);
    VerifyOutGroupEdges(i, OutGroupEdges);
  }
  
  // Test TNGraph which is same as undirected.
  PNGraph GraphTN = TriadGetTestTNGraph();
  for (int i = 0; i < GraphTN->GetNodes(); i++) {
    TIntSet GroupSet;
    GetGroupSet(i, GroupSet);
    int InGroupEdges = -1, InOutGroupEdges = -1, OutGroupEdges = -1;
    TSnap::GetNodeTriads(GraphTN, i, GroupSet, 
                         InGroupEdges, InOutGroupEdges, OutGroupEdges);
    VerifyInGroupEdges(i, InGroupEdges);
    VerifyInOutGroupEdges(i, InOutGroupEdges);
    VerifyOutGroupEdges(i, OutGroupEdges);
  }
  
  // Test TNEGraph which is same as undirected.
  PNEGraph GraphTNE = TriadGetTestTNEGraph();
  for (int i = 0; i < GraphTNE->GetNodes(); i++) {
    TIntSet GroupSet;
    GetGroupSet(i, GroupSet);
    int InGroupEdges = -1, InOutGroupEdges = -1, OutGroupEdges = -1;
    TSnap::GetNodeTriads(GraphTNE, i, GroupSet, 
                         InGroupEdges, InOutGroupEdges, OutGroupEdges);
    VerifyInGroupEdges(i, InGroupEdges);
    VerifyInOutGroupEdges(i, InOutGroupEdges);
    VerifyOutGroupEdges(i, OutGroupEdges);
  }
}
コード例 #2
0
ファイル: Resource.cpp プロジェクト: GCshepard/Diluted-Grain
 bool Resource::BelongsTo(Resource::Group group, Resource::Enum resource) {
     const std::set<Resource::Enum> &groupSet = GetGroupSet(group);
     return (groupSet.find(resource) != groupSet.end());
 }