CountVertexPairsWithBothDirectedEdges
(
IGraph oGraph,
HashSet<Int64> oVertexIDPairsOrdered
)
{
Debug.Assert(oGraph != null);
Debug.Assert(oGraph.Directedness == GraphDirectedness.Directed);
Debug.Assert(oVertexIDPairsOrdered != null);
// Note that each vertex pair connected with both directed edges will
// get counted twice here.
Int32 iVertexPairsWithBothDirectedEdges = 0;
foreach (Int64 oVertexIDPairOrdered in oVertexIDPairsOrdered)
{
// Check whether the HashSet contains a vertex pair with the order
// of the vertex IDs reversed.
Int32 iVertex1ID, iVertex2ID;
CollectionUtil.ParseDictionaryKey(oVertexIDPairOrdered,
out iVertex1ID, out iVertex2ID);
if (oVertexIDPairsOrdered.Contains(
CollectionUtil.GetDictionaryKey(
iVertex2ID, iVertex1ID, true)))
{
iVertexPairsWithBothDirectedEdges++;
}
}
Debug.Assert(iVertexPairsWithBothDirectedEdges % 2 == 0);
return (iVertexPairsWithBothDirectedEdges / 2);
}