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() { #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 }
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 }
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"); }