AlgorithmBlob(TabCanvas tabCanvas) { UIGraph = tabCanvas.GraphCanvas.Graph; AlgorithmGraph = new Choosability.Graph(UIGraph.GetEdgeWeights()); BitGraph = new BitLevelGeneration.BitGraph_long(UIGraph.GetEdgeWeights()); SelectedVertices = UIGraph.Vertices.Select((v, i) => v.IsSelected ? i : -1).Where(x => x >= 0).ToList(); SelectedEdges = UIGraph.Edges.Where(e => e.IsSelected).Select(e => new Tuple <int, int>(UIGraph.Vertices.IndexOf(e.V1), UIGraph.Vertices.IndexOf(e.V2))).ToList(); EdgeIndexLookup = new Dictionary <Tuple <int, int>, int>(); int k = 0; for (int i = 0; i < AlgorithmGraph.N; i++) { for (int j = i + 1; j < AlgorithmGraph.N; j++) { if (AlgorithmGraph[i, j]) { EdgeIndexLookup[new Tuple <int, int>(i, j)] = k; EdgeIndexLookup[new Tuple <int, int>(j, i)] = k; k++; } } } SelectedEdgeIndices = SelectedEdges.Select(tuple => EdgeIndexLookup[tuple]).ToList(); }
public static AlgorithmBlob Create(TabCanvas tabCanvas) { if (tabCanvas == null) { return(null); } return(new AlgorithmBlob(tabCanvas)); }