SortGroupEdges
(
IGraph graph,
Int32 maximumGroups,
Boolean includeDummyGroupForEntireGraph,
Boolean includeDummyGroupForUngroupedEdges
)
{
Debug.Assert(graph != null);
Debug.Assert(maximumGroups > 0);
// Filter out duplicate edges.
IEnumerable<IEdge> oFilteredEdges =
EdgeFilter.FilterEdgesByImportedID(graph.Edges);
// Sort the filtered edges by group.
List<GroupEdgeInfo> oGroupEdgeInfos =
SortFilteredEdgesByGroup(graph, maximumGroups, oFilteredEdges);
if (includeDummyGroupForUngroupedEdges)
{
// This option makes sense only if all groups were asked for.
Debug.Assert(maximumGroups == Int32.MaxValue);
// Append a GroupEdgeInfo object that contains the edges that are
// not contained in any real groups.
oGroupEdgeInfos.Add(
new GroupEdgeInfo(
GetUngroupedEdges(oFilteredEdges, oGroupEdgeInfos),
DummyGroupNameForUngroupedEdges)
);
}
if (includeDummyGroupForEntireGraph)
{
// Insert a GroupEdgeInfo object that contains all the graph's
// edges. Note that this must be the first item in the returned
// collection.
oGroupEdgeInfos.Insert(0,
new GroupEdgeInfo(oFilteredEdges,
DummyGroupNameForEntireGraph)
);
}
return (oGroupEdgeInfos);
}