public MainWindowViewModel() { Graph = new PocGraph(true); List<PocVertex> existingVertices = new List<PocVertex>(); existingVertices.Add(new PocVertex("Sacha Barber", true)); //0 existingVertices.Add(new PocVertex("Sarah Barber", false)); //1 existingVertices.Add(new PocVertex("Marlon Grech", true)); //2 existingVertices.Add(new PocVertex("Daniel Vaughan", true)); //3 existingVertices.Add(new PocVertex("Bea Costa", false)); //4 foreach (PocVertex vertex in existingVertices) Graph.AddVertex(vertex); //add some edges to the graph AddNewGraphEdge(existingVertices[0], existingVertices[1]); AddNewGraphEdge(existingVertices[0], existingVertices[2]); AddNewGraphEdge(existingVertices[0], existingVertices[3]); AddNewGraphEdge(existingVertices[0], existingVertices[4]); AddNewGraphEdge(existingVertices[1], existingVertices[0]); AddNewGraphEdge(existingVertices[1], existingVertices[2]); AddNewGraphEdge(existingVertices[1], existingVertices[3]); AddNewGraphEdge(existingVertices[2], existingVertices[0]); AddNewGraphEdge(existingVertices[2], existingVertices[1]); AddNewGraphEdge(existingVertices[2], existingVertices[3]); AddNewGraphEdge(existingVertices[2], existingVertices[4]); AddNewGraphEdge(existingVertices[3], existingVertices[0]); AddNewGraphEdge(existingVertices[3], existingVertices[1]); AddNewGraphEdge(existingVertices[3], existingVertices[3]); AddNewGraphEdge(existingVertices[3], existingVertices[4]); AddNewGraphEdge(existingVertices[4], existingVertices[0]); AddNewGraphEdge(existingVertices[4], existingVertices[2]); AddNewGraphEdge(existingVertices[4], existingVertices[3]); string edgeString = string.Format("{0}-{1} Connected", existingVertices[0].ID, existingVertices[0].ID); Graph.AddEdge(new PocEdge(edgeString, existingVertices[0], existingVertices[1])); Graph.AddEdge(new PocEdge(edgeString, existingVertices[0], existingVertices[1])); Graph.AddEdge(new PocEdge(edgeString, existingVertices[0], existingVertices[1])); Graph.AddEdge(new PocEdge(edgeString, existingVertices[0], existingVertices[1])); //Add Layout Algorithm Types layoutAlgorithmTypes.Add("BoundedFR"); layoutAlgorithmTypes.Add("Circular"); layoutAlgorithmTypes.Add("CompoundFDP"); layoutAlgorithmTypes.Add("EfficientSugiyama"); layoutAlgorithmTypes.Add("FR"); layoutAlgorithmTypes.Add("ISOM"); layoutAlgorithmTypes.Add("KK"); layoutAlgorithmTypes.Add("LinLog"); layoutAlgorithmTypes.Add("Tree"); //Pick a default Layout Algorithm Type LayoutAlgorithmType = "LinLog"; }
partial void CreateSampleGraphs() { var graph = new PocGraph(); var from = new PocVertex("Force", 32); graph.AddVertex(from); Add(graph, from, TestTagViewModel.Create(), 0, 16); GraphModels.Add(new GraphModel("Fa", graph)); SelectedGraphModel = GraphModels.First(); }
partial void CreateSampleGraphs() { #region SimpleTree int i = 0; { var graph = new PocGraph(); for (int j = 0; j < 11; i++, j++) { var v = new PocVertex(i.ToString()); graph.AddVertex(v); v.Desc = "test" + i.ToString(); } graph.AddEdge(new PocEdge("StartToImporter", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("ImporterToTarget", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(2))); graph.AddEdge(new PocEdge("ImporterToSource", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(3))); // Target Side graph.AddEdge(new PocEdge("TargetCleanupToStopword", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(4))); graph.AddEdge(new PocEdge("TargetStopwordToStemmer", graph.Vertices.ElementAt(4), graph.Vertices.ElementAt(6))); graph.AddEdge(new PocEdge("TargetStemmerToDictionary", graph.Vertices.ElementAt(6), graph.Vertices.ElementAt(8))); graph.AddEdge(new PocEdge("TargetDictionaryToTracer", graph.Vertices.ElementAt(8), graph.Vertices.ElementAt(9))); // Source side graph.AddEdge(new PocEdge("SourceCleanupToStopword", graph.Vertices.ElementAt(3), graph.Vertices.ElementAt(5))); graph.AddEdge(new PocEdge("SourceStopwordToStemmer", graph.Vertices.ElementAt(5), graph.Vertices.ElementAt(7))); graph.AddEdge(new PocEdge("SourceStemmerToTracer", graph.Vertices.ElementAt(7), graph.Vertices.ElementAt(9))); graph.AddEdge(new PocEdge("DecisionToImporter", graph.Vertices.ElementAt(9), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("DecisionToEnd", graph.Vertices.ElementAt(9), graph.Vertices.ElementAt(10))); GraphModels.Add(new GraphModel("Fa", graph)); } { var graph = new PocGraph(); for (int j = 0; j < 2; i++, j++) { var v = new PocVertex(i.ToString()); graph.AddVertex(v); v.Desc = "test" + i.ToString(); } graph.AddEdge(new PocEdge("StartToImporter", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); GraphModels.Add(new GraphModel("Fb", graph)); } #endregion }
public GraphProvider() { item_provider = new ItemProvider(); Graph = new PocGraph(true); root_vertex = new FileBrowser(""); graph.AddVertex(root_vertex); //layoutAlgorithmType = "EfficientSugiyama"; //LayoutAlgorithmType="Circular" //LayoutAlgorithmType="CompundFDP" //LayoutAlgorithmType="EfficientSugiyama" //LayoutAlgorithmType="FR" //LayoutAlgorithmType="ISOM" //LayoutAlgorithmType="KK" //LayoutAlgorithmType="LinLog" //LayoutAlgorithmType="Tree" SaveFile = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".vizzy"; }
private void Add(PocGraph graph, PocVertex from, TestTagViewModelCollection tags, int level, int fontsize) { if (tags == null) { return; } if (level > 2) { return; } foreach (TestTagViewModel model in tags) { var to = new PocVertex(model.Text, fontsize); graph.AddVertex(to); graph.AddEdge(new PocEdge(Guid.NewGuid().ToString(), from, to)); Add(graph, to, model.Tags, level + 1, fontsize / 2); } }
partial void CreateSampleGraphs() { var graph = new PocGraph(); for (int i = 0; i < 8; i++) { var v = new PocVertex(i.ToString(CultureInfo.InvariantCulture)); graph.AddVertex(v); } graph.AddEdge(new PocEdge("0to1", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("1to2", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(2))); graph.AddEdge(new PocEdge("2to3", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(3))); graph.AddEdge(new PocEdge("2to4", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(4))); graph.AddEdge(new PocEdge("0to5", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(5))); graph.AddEdge(new PocEdge("1to7", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(7))); graph.AddEdge(new PocEdge("4to6", graph.Vertices.ElementAt(4), graph.Vertices.ElementAt(6))); GraphModels.Add(new GraphModel("Fa", graph)); SelectedGraphModel = GraphModels.First(); }
partial void CreateSampleGraphs() { #region SimpleTree var graph = new PocGraph(); for (int i = 0; i < 8; i++) { var v = new PocVertex(i.ToString()); graph.AddVertex(v); } graph.AddEdge(new PocEdge("0to1", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("1to2", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(2))); graph.AddEdge(new PocEdge("2to3", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(3))); graph.AddEdge(new PocEdge("2to4", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(4))); graph.AddEdge(new PocEdge("0to5", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(5))); graph.AddEdge(new PocEdge("1to7", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(7))); graph.AddEdge(new PocEdge("4to6", graph.Vertices.ElementAt(4), graph.Vertices.ElementAt(6))); GraphModels.Add(new GraphModel("Fa", graph)); #endregion }
private void CreateGraph() { Graph = new PocGraph(true); //Module mod = _module; var uniqueFac = mod.Modules.Select(o => o.Flow_station).Distinct().ToList(); //NumberOfFacs = uniqueFac.Count(); //for (int j = 0; j < uniqueFac.Count; j++) //{ List <string> _UniqueFS = new List <string>(); List <string> _UniqueWN = new List <string>(); List <string> _UniqueM = new List <string>(); List <string> _UniqueDP = new List <string>(); List <string> _UniqueRE = new List <string>(); List <string> _UniqueF = new List <string>(); List <string> _RawFS = new List <string>(); List <string> _RawWN = new List <string>(); List <string> _RawM = new List <string>(); List <string> _RawDP = new List <string>(); List <string> _RawRE = new List <string>(); List <string> _RawF = new List <string>(); Dictionary <string, PocVertex> _NewVerticesFlow_station = new Dictionary <string, PocVertex>(); Dictionary <string, PocVertex> _NewVerticesWellName = new Dictionary <string, PocVertex>(); Dictionary <string, PocVertex> _NewVerticesModule_ = new Dictionary <string, PocVertex>(); Dictionary <string, PocVertex> _NewVerticesDrainage_Point = new Dictionary <string, PocVertex>(); Dictionary <string, PocVertex> _NewVerticesReservoir = new Dictionary <string, PocVertex>(); Dictionary <string, PocVertex> _NewVerticesField = new Dictionary <string, PocVertex>(); Dictionary <string, string> _FS_WN = new Dictionary <string, string>(); Dictionary <string, string> _WN_M = new Dictionary <string, string>(); Dictionary <string, string> _M_DP = new Dictionary <string, string>(); Dictionary <string, string> _DP_R = new Dictionary <string, string>(); Dictionary <string, string> _R_F = new Dictionary <string, string>(); Dictionary <string, PocVertex> _NewVerticesAM = new Dictionary <string, PocVertex>(); #region Root Node(s) - All Levels foreach (var modval in mod.Modules) { if (modval.Flow_station.ToString() == uniqueFac[Facility_ID]) { if (!_NewVerticesFlow_station.ContainsKey(modval.Flow_station)) { _NewVerticesFlow_station.Add(modval.Flow_station, new PocVertex(modval.Flow_station, 0)); //0 _UniqueFS.Add(modval.Flow_station); } _RawFS.Add(modval.Flow_station); _RawWN.Add(modval.WellName); _RawM.Add(modval.Module_); _RawDP.Add(modval.Drainage_Point); _RawRE.Add(modval.Reservoir); _RawF.Add(modval.Field); if (!_NewVerticesWellName.ContainsKey(modval.WellName)) { _NewVerticesWellName.Add(modval.WellName, new PocVertex(modval.WellName, 1)); //1 _UniqueWN.Add(modval.WellName); } if (!_NewVerticesModule_.ContainsKey(modval.Module_)) { _NewVerticesModule_.Add(modval.Module_, new PocVertex(modval.Module_, 2)); //2 _UniqueM.Add(modval.Module_); // } if (!_NewVerticesDrainage_Point.ContainsKey(modval.Drainage_Point)) { _NewVerticesDrainage_Point.Add(modval.Drainage_Point, new PocVertex(modval.Drainage_Point, 3)); //3 _UniqueDP.Add(modval.Drainage_Point); // } if (!_NewVerticesReservoir.ContainsKey(modval.Reservoir)) { _NewVerticesReservoir.Add(modval.Reservoir, new PocVertex(modval.Reservoir, 4)); //4 _UniqueRE.Add(modval.Reservoir); } if (!_NewVerticesField.ContainsKey(modval.Field)) { _NewVerticesField.Add(modval.Field, new PocVertex(modval.Field, 5)); //5 _UniqueF.Add(modval.Field); } } } #endregion int width_ = _NewVerticesModule_.Count; foreach (KeyValuePair <string, PocVertex> vertex in _NewVerticesFlow_station) { Graph.AddVertex(vertex.Value); } foreach (KeyValuePair <string, PocVertex> vertex in _NewVerticesWellName) { Graph.AddVertex(vertex.Value); } foreach (KeyValuePair <string, PocVertex> vertex in _NewVerticesModule_) { Graph.AddVertex(vertex.Value); } foreach (KeyValuePair <string, PocVertex> vertex in _NewVerticesDrainage_Point) { Graph.AddVertex(vertex.Value); } foreach (KeyValuePair <string, PocVertex> vertex in _NewVerticesReservoir) { Graph.AddVertex(vertex.Value); } foreach (KeyValuePair <string, PocVertex> vertex in _NewVerticesField) { Graph.AddVertex(vertex.Value); } for (int a = 0; a < _RawWN.Count(); a++) { AddNewGraphEdge(_NewVerticesFlow_station[_RawFS[a]], _NewVerticesWellName[_RawWN[a]]); AddNewGraphEdge(_NewVerticesWellName[_RawWN[a]], _NewVerticesModule_[_RawM[a]]); AddNewGraphEdge(_NewVerticesModule_[_RawM[a]], _NewVerticesDrainage_Point[_RawDP[a]]); AddNewGraphEdge(_NewVerticesDrainage_Point[_RawDP[a]], _NewVerticesReservoir[_RawRE[a]]); AddNewGraphEdge(_NewVerticesReservoir[_RawRE[a]], _NewVerticesField[_RawF[a]]); } //Add Layout Algorithm Types layoutAlgorithmTypes.Add("BoundedFR"); layoutAlgorithmTypes.Add("Circular"); layoutAlgorithmTypes.Add("CompoundFDP"); layoutAlgorithmTypes.Add("EfficientSugiyama"); layoutAlgorithmTypes.Add("FR"); layoutAlgorithmTypes.Add("ISOM"); layoutAlgorithmTypes.Add("KK"); layoutAlgorithmTypes.Add("LinLog"); layoutAlgorithmTypes.Add("Tree"); //Pick a default Layout Algorithm Type LayoutAlgorithmType = "Tree"; //} }
public void LoadProject(string filename) { using (Package package = Package.Open(filename, FileMode.OpenOrCreate)) { Properties.Settings.Default.PreviousFile = filename; XmlSerializer vertex_loader = new XmlSerializer(typeof(PocVertex)); graph = new PocGraph(true); foreach (var p in package.GetParts()) { if (p.ContentType == "text/xml" && p.Uri.OriginalString.StartsWith("/vertices") && !p.Uri.OriginalString.EndsWith(".rels") ) { PocVertex new_vertex = (PocVertex)vertex_loader.Deserialize(p.GetStream(FileMode.Open)); graph.AddVertex(new_vertex); } } foreach (var p in package.GetParts()) { if (p.ContentType == "text/xml" && p.Uri.OriginalString.StartsWith("/vertices") && !p.Uri.OriginalString.EndsWith(".rels") ) { PocVertex new_vertex = (PocVertex)vertex_loader.Deserialize(p.GetStream(FileMode.Open)); PocVertex source = graph.Vertices.Where(x => x.ID == new_vertex.ID).First(); var edges = p.GetRelationshipsByType(EdgeRelationship); foreach (var edge in edges) { new_vertex = (PocVertex)vertex_loader.Deserialize(package.GetPart(edge.TargetUri).GetStream(FileMode.Open)); PocVertex target = graph.Vertices.Where(x => x.ID == new_vertex.ID).First(); PocEdge new_edge = new PocEdge(source, target); if (!(source == target)) { graph.AddEdge(new_edge); } } } else if (p.Uri.OriginalString == "/notes/notes.txt") { using (var sr = new StreamReader(p.GetStream())) { graph.Notes.Text = sr.ReadToEnd(); } } } root_vertex = (FileBrowser)graph.Vertices.Where(x => (x as FileBrowser) != null).First(); item_provider.RootDir = root_vertex.FilePath; root_dir = root_vertex.FilePath; } UsingTempFile = false; SaveFile = filename; NotifyPropertyChanged("Graph"); }