Exemplo n.º 1
0
        public IExternalEdgeRouting <TVertex, TEdge> CreateEdgeRoutingAlgorithm(EdgeRoutingAlgorithmTypeEnum newAlgorithmType, Rect graphArea, TGraph iGraph, IDictionary <TVertex, Point> positions, IDictionary <TVertex, Rect> rectangles, IEdgeRoutingParameters parameters = null)
        {
            //if (Rectangles == null) return null;
            if (parameters == null)
            {
                parameters = CreateEdgeRoutingParameters(newAlgorithmType);
            }
            IMutableBidirectionalGraph <TVertex, TEdge> graph = iGraph.CopyToBidirectionalGraph();

            graph.RemoveEdgeIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude);
            graph.RemoveVertexIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude);

            switch (newAlgorithmType)
            {
            case EdgeRoutingAlgorithmTypeEnum.SimpleER:
                return(new SimpleEdgeRouting <TVertex, TEdge, TGraph>((TGraph)graph, positions, rectangles, parameters));

            case EdgeRoutingAlgorithmTypeEnum.Bundling:
                return(new BundleEdgeRouting <TVertex, TEdge, TGraph>(graphArea, (TGraph)graph, positions, rectangles, parameters));

            case EdgeRoutingAlgorithmTypeEnum.PathFinder:
                return(new PathFinderEdgeRouting <TVertex, TEdge, TGraph>((TGraph)graph, positions, rectangles, parameters));

            default:
                return(null);
            }
        }
Exemplo n.º 2
0
        public static void CutNonReachable <TVertex, TEdge>(this IMutableBidirectionalGraph <TVertex, TEdge> graph,
                                                            IEnumerable <TVertex> toKeep)
            where TEdge : IEdge <TVertex>
        {
            var reachable = graph.FindReachable(toKeep);

            graph.RemoveVertexIf(x => !reachable.Contains(x));
        }
Exemplo n.º 3
0
        public ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateLayoutAlgorithm(LayoutAlgorithmTypeEnum newAlgorithmType, TGraph iGraph, IDictionary <TVertex, Point> positions = null, IDictionary <TVertex, Size> sizes = null, ILayoutParameters parameters = null)
        {
            if (iGraph == null)
            {
                return(null);
            }
            if (parameters == null)
            {
                parameters = CreateLayoutParameters(newAlgorithmType);
            }
            IMutableBidirectionalGraph <TVertex, TEdge> graph = iGraph.CopyToBidirectionalGraph();

            /*var dic = new Dictionary<TVertex, Point>();
             * if (Positions != null)
             * {
             *  dic = Positions.Where(a => a.Key.SkipProcessing == ProcessingOptionEnum.Freeze).ToDictionary(a=> a.Key, a=> a.Value);
             * }*/
            graph.RemoveEdgeIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude);
            graph.RemoveVertexIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude);

            switch (newAlgorithmType)
            {
            case LayoutAlgorithmTypeEnum.Tree:
                return(new SimpleTreeLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions, sizes, parameters as SimpleTreeLayoutParameters));

            case LayoutAlgorithmTypeEnum.SimpleRandom:
                return(new RandomLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions));

            case LayoutAlgorithmTypeEnum.Circular:
                return(new CircularLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions, sizes, parameters as CircularLayoutParameters));

            case LayoutAlgorithmTypeEnum.FR:
                return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions, parameters as FRLayoutParametersBase));

            case LayoutAlgorithmTypeEnum.BoundedFR:
                return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions, parameters as BoundedFRLayoutParameters));

            case LayoutAlgorithmTypeEnum.KK:
                return(new KKLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions, parameters as KKLayoutParameters));

            case LayoutAlgorithmTypeEnum.ISOM:
                return(new ISOMLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions, parameters as ISOMLayoutParameters));

            case LayoutAlgorithmTypeEnum.LinLog:
                return(new LinLogLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, positions, parameters as LinLogLayoutParameters));

            case LayoutAlgorithmTypeEnum.EfficientSugiyama:
                return(new EfficientSugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, parameters as EfficientSugiyamaLayoutParameters, positions, sizes));

            case LayoutAlgorithmTypeEnum.Sugiyama:
                return(new SugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, sizes, positions, parameters as SugiyamaLayoutParameters,
                                                                            e => (e is TypedEdge <TVertex>
                                                                                  ?(e as TypedEdge <TVertex>).Type
                                                                                  : EdgeTypes.Hierarchical)));

            case LayoutAlgorithmTypeEnum.CompoundFDP:
                return(new CompoundFDPLayoutAlgorithm <TVertex, TEdge, TGraph>((TGraph)graph, sizes, new Dictionary <TVertex, Thickness>(), new Dictionary <TVertex, CompoundVertexInnerLayoutType>(),
                                                                               positions, parameters as CompoundFDPLayoutParameters));

            /*case LayoutAlgorithmTypeEnum.BalloonTree:
             *  return new BalloonTreeLayoutAlgorithm<TVertex, TEdge, TGraph>(Graph, Positions, Sizes, parameters as BalloonTreeLayoutParameters, Graph.Vertices.FirstOrDefault());*/
            default:
                return(null);
            }
        }