TestCalculateGraphMetrics4()
{
// Directed graph, sample from http://
// faculty.ucr.edu/~hanneman/nettext/C8_Embedding.html#reciprocity
//
// ...but with random duplicate edges. The duplicate edges should not
// affect the results.
Boolean bIsDirected = true;
CreateGraph(bIsDirected);
IVertex oVertexA = m_oVertices.Add();
IVertex oVertexB = m_oVertices.Add();
IVertex oVertexC = m_oVertices.Add();
Random oRandom = new Random();
for (Int32 i = 0; i < 10; i++)
{
for (Int32 j = 0; j < oRandom.Next(1, 100); j++)
{
m_oEdges.Add(oVertexA, oVertexB, bIsDirected);
}
for (Int32 j = 0; j < oRandom.Next(1, 100); j++)
{
m_oEdges.Add(oVertexB, oVertexA, bIsDirected);
}
for (Int32 j = 0; j < oRandom.Next(1, 100); j++)
{
m_oEdges.Add(oVertexB, oVertexC, bIsDirected);
}
Nullable<Double> dReciprocatedVertexPairRatio,
dReciprocatedEdgeRatio;
m_oOverallReciprocationCalculator.CalculateGraphMetrics(m_oGraph,
out dReciprocatedVertexPairRatio, out dReciprocatedEdgeRatio);
Assert.AreEqual(0.5, dReciprocatedVertexPairRatio.Value);
Assert.AreEqual(0.667, dReciprocatedEdgeRatio.Value, 0.001);
}
}