Example #1
0
        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";

        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphViewModel"/> class.
 /// </summary>
 public GraphViewModel(
     [NotNull] string name,
     [NotNull] PocGraph graph)
 {
     Name  = name ?? throw new ArgumentNullException(nameof(name));
     Graph = graph ?? throw new ArgumentNullException(nameof(graph));
 }
 public static void SaveGraph(PocGraph graph, string filename)
 {
     using (XmlWriter writer = XmlWriter.Create(filename))
     {
         var serializer = new GraphMLSerializer<PocVertex, PocEdge, PocGraph>();
         serializer.Serialize(writer, graph, v => v.ID, e => e.ID);
     }
 }
 public static void SaveGraph(PocGraph graph, string filename)
 {
     using (XmlWriter writer = XmlWriter.Create(filename))
     {
         var serializer = new GraphMLSerializer <PocVertex, PocEdge, PocGraph>();
         serializer.Serialize(writer, graph, v => v.ID, e => e.ID);
     }
 }
            static PocGraph ConvertToPocGraph(IEdgeListGraph <PocVertex, PocEdge> g)
            {
                var pocGraph = new PocGraph();

                pocGraph.AddVertexRange(g.Vertices);
                pocGraph.AddEdgeRange(g.Edges);

                return(pocGraph);
            }
        public static PocGraph LoadGraph(string filename)
        {
            using (XmlReader reader = XmlReader.Create(filename))
            {
                var serializer = new GraphMLDeserializer<PocVertex, PocEdge, PocGraph>();

                var pocGraph = new PocGraph();
                serializer.Deserialize(reader, pocGraph, id => new PocVertex(id), (source, target, id) => new PocEdge(id, source, target));
                return pocGraph;
            }
        }
        public static PocGraph LoadGraph(string filename)
        {
            using (XmlReader reader = XmlReader.Create(filename))
            {
                var serializer = new GraphMLDeserializer <PocVertex, PocEdge, PocGraph>();

                var pocGraph = new PocGraph();
                serializer.Deserialize(reader, pocGraph, id => new PocVertex(id), (source, target, id) => new PocEdge(id, source, target));
                return(pocGraph);
            }
        }
Example #8
0
        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();
        }
Example #9
0
        /// <summary>
        /// Saves a graph to file.
        /// </summary>
        public static void SaveGraph([NotNull] PocGraph graph, [NotNull] string filePath)
        {
            // Create the xml writer
            using (var writer = XmlWriter.Create(filePath))
            {
                var serializer = new GraphMLSerializer <PocVertex, PocEdge, PocGraph>();

                // Serialize the graph
                serializer.Serialize(writer, graph, v => v.ID, e => e.ID);
            }
        }
        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 static void SaveGraph( PocGraph graph, string filename )
		{
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
          
			//create the xml writer
			using ( var writer = XmlWriter.Create( filename, settings ) )
			{
				var serializer = new GraphMLSerializer<PocVertex, PocEdge, PocGraph>();
                
				//serialize the graph
				serializer.Serialize( writer, graph, v => v.ID, e => e.ID );
			}
		}
		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
        }
Example #13
0
        public static void SaveGraph(PocGraph graph, string filename)
        {
            //            graph.SerializeToBinary()

            using (XmlWriter writer = XmlWriter.Create(filename))
            {
                var serializer = new GraphMLSerializer <PocVertex, PocEdge, PocGraph>();
                serializer.Serialize(writer, graph, v => v.ID, e => e.ID);
            }

            //            using (var stream = File.OpenWrite(filename))
            //            {
            //                graph.SerializeToBinary(stream);
            //            }
        }
        private IBidirectionalGraph <object, IEdge <object> > ConvertGraph(PocGraph graph)
        {
            var g = new CompoundGraph <object, IEdge <object> >();

            foreach (var item in graph.Vertices)
            {
                g.AddVertex(item.ID);
            }

            foreach (var item in graph.Edges)
            {
                g.AddEdge(new Edge <object>(item.Source.ID, item.Target.ID));
            }


            return(g);
        }
Example #15
0
        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";
        }
		public static PocGraph LoadGraph( string filename )
		{
			//open the file of the graph
			var reader = XmlReader.Create( filename );

			//create the serializer
			var serializer = new GraphMLDeserializer<PocVertex, PocEdge, PocGraph>();

			//graph where the vertices and edges should be put in
			var pocGraph = new PocGraph();

			//deserialize the graph
			serializer.Deserialize( reader, pocGraph,
			                        id => new PocVertex( id ),
			                        ( source, target, id ) => new PocEdge( id, source, target ) );

			return pocGraph;
		}
Example #17
0
        public static PocGraph LoadGraph(string filename)
        {
            using (XmlReader reader = XmlReader.Create(filename))
            {
                //QuickGraph.Serialization.SerializationExtensions.

                var serializer = new GraphMLDeserializer <PocVertex, PocEdge, PocGraph>();

                var pocGraph = new PocGraph();
                serializer.Deserialize(reader, pocGraph, id => new PocVertex(id, 10), (source, target, id) => new PocEdge(id, source, target));
                return(pocGraph);
            }

            //            using (var stream = File.OpenRead(filename))
            //            {
            //                return stream.DeserializeFromBinary<PocVertex, PocEdge, PocGraph>();
            //            }
        }
Example #18
0
        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);
            }
        }
Example #19
0
        public static PocGraph LoadGraph([NotNull] string filePath)
        {
            // Open the file of the graph
            using (XmlReader reader = XmlReader.Create(filePath))
            {
                // Create the serializer
                var serializer = new GraphMLDeserializer <PocVertex, PocEdge, PocGraph>();

                // Graph where the vertices and edges should be put in
                var pocGraph = new PocGraph();

                // Deserialize the graph
                serializer.Deserialize(
                    reader,
                    pocGraph,
                    id => new PocVertex(id),
                    (source, target, id) => new PocEdge(id, source, target));

                return(pocGraph);
            }
        }
Example #20
0
        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()
        {
            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
        }
Example #23
0
        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
        }
Example #24
0
 public GraphModel(string name, PocGraph graph)
 {
     Name = name;
     Graph = graph;
 }
        private IBidirectionalGraph<object, IEdge<object>> ConvertGraph(PocGraph graph)
        {
            var g = new CompoundGraph<object, IEdge<object>>();

            foreach (var item in graph.Vertices)
            {
                g.AddVertex(item.ID);

            }

            foreach (var item in graph.Edges)
            {
                g.AddEdge(new Edge<object>(item.Source.ID, item.Target.ID));
            }


            return g;
        }
Example #26
0
        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");
        }
Example #27
0
        public void RunGraph(string startWord, List<Word> wordList)
        {
            Graph = new PocGraph(true);
            existingVertices.Clear();

            this.wordList = wordList;
            var qualifiedWords = EditDistance.GetShortestLevenshtein(startWord, wordList.Select(w => w.Name).ToList());

            existingVertices.Add(new PocVertex(0, startWord, 0));
            int position = 0;
            foreach (KeyValuePair<string, int> w in qualifiedWords)
            {
                existingVertices.Add(new PocVertex(position++, w.Key, w.Value));
            }

            foreach (PocVertex vertex in existingVertices)
                graph.AddVertex(vertex);

            //add some edges to the graph

            for (int i = 0; i < existingVertices.Count; i++)
            {
                AddNewGraphEdge(existingVertices[0], existingVertices[i]);
            }

            //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";
        }
        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";
            //}
        }
        private void CreateSampleGraph()
        {
            #region Simple tree graph

            var graph = new PocGraph();

            PocVertex[] vertices = Enumerable.Range(0, 8).Select(VertexFactory).ToArray();
            graph.AddVertexRange(vertices);
            graph.AddEdgeRange(new []
            {
                EdgeFactory(vertices[0], vertices[1]),
                EdgeFactory(vertices[1], vertices[2]),
                EdgeFactory(vertices[2], vertices[3]),
                EdgeFactory(vertices[2], vertices[4]),
                EdgeFactory(vertices[0], vertices[5]),
                EdgeFactory(vertices[1], vertices[7]),
                EdgeFactory(vertices[4], vertices[6]),
                EdgeFactory(vertices[0], vertices[4])
            });

            GraphModels.Add(new GraphViewModel("Fa", graph));

            #endregion

            #region Complete graph

            IBidirectionalGraph <PocVertex, PocEdge> completeGraph = GraphFactory.CreateCompleteGraph(
                7,
                VertexFactory,
                EdgeFactory);

            GraphModels.Add(new GraphViewModel("Complete", ConvertToPocGraph(completeGraph)));

            #endregion

            #region Isolated vertices graph

            IBidirectionalGraph <PocVertex, PocEdge> isolatedVerticesGraph = GraphFactory.CreateIsolatedVerticesGraph <PocVertex, PocEdge>(
                25,
                VertexFactory);

            GraphModels.Add(new GraphViewModel("Isolated vertices", ConvertToPocGraph(isolatedVerticesGraph)));

            #endregion

            #region General graph

            IBidirectionalGraph <PocVertex, PocEdge> generalGraph = GraphFactory.CreateGeneralGraph(
                30,
                25,
                10,
                true,
                VertexFactory,
                EdgeFactory,
                new Random(123456));

            GraphModels.Add(new GraphViewModel("General graph", ConvertToPocGraph(generalGraph)));

            #endregion

            #region DAG graph

            IBidirectionalGraph <PocVertex, PocEdge> dagGraph = GraphFactory.CreateDAG(
                30,
                25,
                5,
                10,
                true,
                VertexFactory,
                EdgeFactory,
                new Random(123456));

            GraphModels.Add(new GraphViewModel("DAG graph", ConvertToPocGraph(dagGraph)));

            #endregion

            #region Tree graph

            IBidirectionalGraph <PocVertex, PocEdge> treeGraph = GraphFactory.CreateTree(
                25,
                3,
                VertexFactory,
                EdgeFactory,
                new Random(123456));

            GraphModels.Add(new GraphViewModel("Tree graph", ConvertToPocGraph(treeGraph)));
Example #30
0
 public GraphModel(string name, PocGraph graph)
 {
     Name  = name;
     Graph = graph;
 }