Problem with calculating group metrics

Nov 15, 2011 at 11:04 PM

This is the error message appearing when attempting to calculate group metrics: 

---------------------------NodeXL---------------------------An unexpected problem occurred.  If it occurs again, please copy the details to the clipboard by typing Ctrl-C, then post the details to http://www.codeplex.com/NodeXL/Thread/List.aspx.


Details:


[ArgumentException]: An item with the same key has already been added.


   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Smrf.NodeXL.Algorithms.SubgraphCalculator.GetSubgraphAsNewGraph(ICollection`1 verticesToInclude)
   at Smrf.NodeXL.ExcelTemplate.GroupMetricCalculator2.TryCalculateGraphMetricsForOneGroup(ExcelTemplateGroupInfo oExcelTemplateGroupInfo, CalculateGraphMetricsContext oCalculateGraphMetricsContext, OverallMetrics& oOverallMetrics)
   at Smrf.NodeXL.ExcelTemplate.GroupMetricCalculator2.TryCalculateGraphMetrics(IGraph graph, CalculateGraphMetricsContext calculateGraphMetricsContext, GraphMetricColumn[]& graphMetricColumns)
   at Smrf.NodeXL.ExcelTemplate.GraphMetricCalculationManager.CalculateGraphMetricsAsyncInternal(CalculateGraphMetricsAsyncArgs oCalculateGraphMetricsAsyncArgs, BackgroundWorker oBackgroundWorker, DoWorkEventArgs oDoWorkEventArgs)
   at Smrf.NodeXL.ExcelTemplate.GraphMetricCalculationManager.BackgroundWorker_DoWork(Object sender, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)---------------------------OK   ---------------------------

 

Daniel

Nov 15, 2011 at 11:25 PM

Daniel:

Is this repeatable?  In other words, does it happen in this particular workbook every time you attempt to calculate graph metrics?  If so, can you post the workbook?  That will allow me to attempt to reproduce and track down the bug.  (Obviously, this isn't supposed to occur.)

You can't post a file to the Discussions tab on CodePlex, but you can on the Issue Tracker tab at http://nodexl.codeplex.com/workitem/list/basic.

Thanks,
    Tony

Nov 15, 2011 at 11:35 PM

It is repeatable, but due to the nature of the project I am working on, I cannot post it for open viewing. Is there any other way to potentially resolve my problem?

 

Nov 16, 2011 at 12:09 AM

The error message is telling me that there is a group that contains the same vertex twice, which should never occur.  I can think of two ways that this situation might arise:

1. You used a menu item on the NodeXL, Analysis, Groups menu to create the groups, and the part of NodeXL that creates groups has a bug I haven't heard about that puts the same vertex into the same group twice.

2. Someone manually created or edited groups, and made a mistake while doing so.  The mistake would consist of including the same vertex twice in the same group on the Group Vertices worksheet, which usually shouldn't be edited.  I can reproduce the error message you posted by doing just that.

How did you create your groups, and did you attempt to edit them afterward?

-- Tony

Nov 16, 2011 at 12:39 AM

I manually created the groups and have been editing the group vertices sheet fairly consistently. I didn't know that doing so would cause problems. Is there any way to fix this not that I have already been editing?

Nov 16, 2011 at 12:42 AM

I have deleted duplicates. Now, this comes up: 

 

---------------------------NodeXL---------------------------An unexpected problem occurred.  If it occurs again, please copy the details to the clipboard by typing Ctrl-C, then post the details to http://www.codeplex.com/NodeXL/Thread/List.aspx.


Details:


[KeyNotFoundException]: The given key was not present in the dictionary.


   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Smrf.NodeXL.Algorithms.IntergroupEdgeCalculator.IncidentEdgeShouldBeCounted(IEdge oIncidentEdge, IVertex oVertexInGroup1, Int32 iGroup1Index, Dictionary`2 oGroupIndexDictionary, Boolean bUseDirectedness, Boolean bGraphIsDirected, Int32& iGroup2Index)
   at Smrf.NodeXL.Algorithms.IntergroupEdgeCalculator.TryCalculateGraphMetrics(IGraph graph, BackgroundWorker backgroundWorker, IList`1 groups, Boolean useDirectedness, IList`1& graphMetrics)
   at Smrf.NodeXL.ExcelTemplate.IntergroupEdgeCalculator2.TryCalculateGraphMetrics(IGraph graph, CalculateGraphMetricsContext calculateGraphMetricsContext, GraphMetricColumn[]& graphMetricColumns)
   at Smrf.NodeXL.ExcelTemplate.GraphMetricCalculationManager.CalculateGraphMetricsAsyncInternal(CalculateGraphMetricsAsyncArgs oCalculateGraphMetricsAsyncArgs, BackgroundWorker oBackgroundWorker, DoWorkEventArgs oDoWorkEventArgs)
   at Smrf.NodeXL.ExcelTemplate.GraphMetricCalculationManager.BackgroundWorker_DoWork(Object sender, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)---------------------------OK   ---------------------------

Nov 16, 2011 at 1:47 AM
Edited Nov 16, 2011 at 1:47 AM

This one is caused by a "Vertex" cell on the Group Vertices worksheet that contains the name of a vertex that doesn't exist on the Vertices worksheet.

Are you familiar with the NodeXL, Analysis, Groups, Add Selected Vertices to Group menu item?  It allows you to create groups by selecting vertices and specifying a group name.  You don't have to touch the Group Vertices worksheet at all.

By the way, we're considering doing away with the Group Vertices worksheet entirely and replacing it with a simple "Group" column on the Vertices worksheet to indicate which group, if any, a vertex belongs to.  The Group Vertices worksheet was intended to enable some advanced features that we're no longer going to implement, and the extra worksheet is too complicated, confusing, and (as you've discovered) susceptible to manual corruption.

-- Tony


Nov 16, 2011 at 8:54 PM

I see. Thanks for the update. I never knew about that tool. If I clear the contents of my the group vertices sheet, will this fix my problem?

Nov 17, 2011 at 1:47 AM
Edited Nov 17, 2011 at 1:50 AM

Daniel:

You can fix the problem by clearing both the Groups and Group Vertices worksheets (they work as a pair), but then you'll have to create your groups again.  If you go that route, please use NodeXL, Analysis, Groups, Remove All Groups instead.  That will clear the two worksheets for you.

You could also try to scan the Group Vertices worksheet to spot the problems and fix them.  The practicality of that route depends on how big your worksheet is.

For future workbooks, you should be able to do all your groups tasks via the Groups menu, without having to manually edit either worksheet.  Check out the "Working with Groups" topic at NodeXL, Help, Help for a quick overview.

-- Tony

Nov 18, 2011 at 12:12 AM

Thanks again. Another question that is exclusive from this thread's topic: 

If I want to draw a underlying picture in my graph(like a formalized org chart), how would I do so? Is this possible?

Nov 18, 2011 at 4:51 PM

You can add a background image to the graph:

1. Go to Graph Options at the top of the graph pane.  (It will be hidden behind a "down arrow" if your graph pane is narrow.)

2. Select the "Other" tab in the Graph Options dialog box.

3. Specify the background image.

The background image is shown exactly as is.  We don't make any attempt to scale it to the graph pane, which would distort it.

-- Tony

Nov 18, 2011 at 5:17 PM

Is there any way to save layouts when I configure them the way I want?

Nov 18, 2011 at 5:23 PM

I'm moving this to a new discussion to make it easier for others to find:

http://nodexl.codeplex.com/discussions/280035

-- Tony