Skip to content

Commit

Permalink
accept faillure of SortedDictionary.operator[int] when the key is not…
Browse files Browse the repository at this point in the history
… present.
  • Loading branch information
levnach committed Jul 17, 2024
1 parent e698d19 commit e1ec242
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions GraphLayout/Drawing/Graph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ public void AddPrecalculatedEdge(Edge edge) {
/// <param name="nodeId"></param>
/// <returns></returns>
public Node FindNode(string nodeId) {
return nodeMap[nodeId] as Node;
if (nodeMap.TryGetValue(nodeId, out Node n))
return n;
return null;
}

/// <summary>
Expand All @@ -332,7 +334,8 @@ public Microsoft.Msagl.Core.Layout.Node FindGeometryNode(string nodeId)
{
if (GeometryGraph != null)
{
Node node = nodeMap[nodeId] as Node;

nodeMap.TryGetValue(nodeId, out Node node);
if (node != null)
{
return GeometryGraph.FindNodeByUserData(node);
Expand Down

0 comments on commit e1ec242

Please sign in to comment.