示例#1
0
        public static GraphExample GenerateSugiDataGraph()
        {
            var graph = new GraphExample();

            foreach (var item in DataSource.Take(25))
            {
                graph.AddVertex(new DataVertex(item.Text)
                {
                    ImageId = Rand.Next(0, 3)
                });
            }

            var vList  = graph.Vertices.ToList();
            var edgeId = 1;

            //1 tier
            graph.AddNewEdge(vList[0], vList[1], ++edgeId);
            graph.AddNewEdge(vList[0], vList[2], ++edgeId);
            graph.AddNewEdge(vList[0], vList[3], ++edgeId);
            graph.AddNewEdge(vList[0], vList[4], ++edgeId);
            //2 tier
            graph.AddNewEdge(vList[1], vList[5], ++edgeId);
            graph.AddNewEdge(vList[1], vList[6], ++edgeId);
            graph.AddNewEdge(vList[2], vList[7], ++edgeId);
            graph.AddNewEdge(vList[2], vList[8], ++edgeId);
            graph.AddNewEdge(vList[3], vList[1], ++edgeId);
            graph.AddNewEdge(vList[4], vList[9], ++edgeId);
            graph.AddNewEdge(vList[4], vList[9], ++edgeId);
            //3 tier
            graph.AddNewEdge(vList[8], vList[10], ++edgeId);
            graph.AddNewEdge(vList[8], vList[11], ++edgeId);
            graph.AddNewEdge(vList[8], vList[12], ++edgeId);

            return(graph);
        }