protected void AddSpanVertexToPotentialDConnectorMotifs (IVertex oPotentialSpanVertex, ICollection<IVertex> oDPotentialAnchorVertices, Dictionary<string, DConnectorMotif> oPotentialDConnectorMotifs) { Debug.Assert(oPotentialSpanVertex != null); Debug.Assert(oDPotentialAnchorVertices != null); Debug.Assert(oDPotentialAnchorVertices.Count >= 2); Debug.Assert(oPotentialDConnectorMotifs != null); // Is there already a DConnectorMotif object for this set of // potential anchor vertices? IOrderedEnumerable<IVertex> oOrderedDPotentialAnchorVertices = oDPotentialAnchorVertices.OrderBy(v => v.ID); string stringKey = string.Join(",", oOrderedDPotentialAnchorVertices.Select(v => v.ID.ToString()).ToArray()); DConnectorMotif oPotentialDConnectorMotif; if (!oPotentialDConnectorMotifs.TryGetValue( stringKey, out oPotentialDConnectorMotif)) { // No. Create one. oPotentialDConnectorMotif = new DConnectorMotif(new List<IVertex>(oDPotentialAnchorVertices)); oPotentialDConnectorMotifs.Add(stringKey, oPotentialDConnectorMotif); } oPotentialDConnectorMotif.SpanVertices.Add(oPotentialSpanVertex); }
private static void AddDConnectorMotif (HashSet<Motif> currentDConnectorMotifs, Dictionary<IVertex, DConnectorMotif> verticesAlreadyInDConnectorMotifs, DConnectorMotif connectorMotifToAdd) { // Assert that there are no shared anchor and span vertices Debug.Assert(connectorMotifToAdd.SpanVertices.Intersect<IVertex>(connectorMotifToAdd.AnchorVertices).Count<IVertex>() == 0); currentDConnectorMotifs.Add(connectorMotifToAdd); foreach (IVertex oVertex in connectorMotifToAdd.SpanVertices) { // We do not allow overlapping span vertices so we use .Add verticesAlreadyInDConnectorMotifs.Add(oVertex, connectorMotifToAdd); } foreach (IVertex oVertex in connectorMotifToAdd.AnchorVertices) { // We allow overlapping anchor vertices so we use = verticesAlreadyInDConnectorMotifs[oVertex] = connectorMotifToAdd; } }