コード例 #1
0
        private static IEnumerable<IList<Node>> FindCycles(HashSet<Node> unvisited, Node current, HashSet<Node> visited)
        {
            foreach (var inNode in current.In.Select(edge => edge.Source))
            {
                if (visited.Contains(inNode))
                {
                    yield return new List<Node> { inNode, current };
                }
                else
                {
                    var visitedCopy = new HashSet<Node>(visited);
                    visitedCopy.Add(inNode);
                    unvisited.Remove(inNode);

                    foreach (var cycle in FindCycles(unvisited, inNode, visitedCopy))
                    {
                        if (cycle.First() != cycle.Last())
                        {
                            cycle.Add(current);
                        }

                        yield return cycle;
                    }
                }
            }
        }
コード例 #2
0
 public void Add( Node node )
 {
     if( !TryAdd( node ) )
     {
         throw new ArgumentException( "Node already exists: " + node.Id );
     }
 }
コード例 #3
0
        public Edge TryAddEdge( string sourceNodeId, string targetNodeId )
        {
            var sourceNode = Graph.FindNode( sourceNodeId );
            if( sourceNode == null )
            {
                // support just adding edges - add nodes implicitly
                sourceNode = new Node( sourceNodeId );
                myGraph.TryAdd( sourceNode );
            }

            var targetNode = Graph.FindNode( targetNodeId );
            if( targetNode == null )
            {
                // support just adding edges - add nodes implicitly
                targetNode = new Node( targetNodeId );
                myGraph.TryAdd( targetNode );
            }

            var edge = new Edge( sourceNode, targetNode );

            if( !myGraph.TryAdd( edge ) )
            {
                return null;
            }

            edge.Source.Out.Add( edge );
            edge.Target.In.Add( edge );

            return edge;
        }
コード例 #4
0
        private void OnEventFocused(Node node)
        {
            if (node != null)
            {
                Navigation.NavigateTo(node);

                //myGraphViewer.GraphVisual.Presentation.GetModuleFor<SelectionState>().Get( selectedNode.Id ).IsSelected = true;
            }
        }
コード例 #5
0
        public bool Pick( Node node )
        {
            if( !myCache.ContainsKey( node.Id ) )
            {
                myCache[ node.Id ] = myPicking.Pick( node );
            }

            return myCache[ node.Id ];
        }
コード例 #6
0
        public Edge( Node source, Node target )
        {
            Contract.RequiresNotNull( source, "source" );
            Contract.RequiresNotNull( target, "target" );

            Source = source;
            Target = target;

            Id = CreateId( Source.Id, Target.Id );
        }
コード例 #7
0
 public override bool? IsSet( Node node )
 {
     if( myValues.Contains( node.Id ) )
     {
         return IsShowMask;
     }
     else
     {
         return null;
     }
 }
コード例 #8
0
        public void Set( Node node )
        {
            if( myValues.Contains( node.Id ) )
            {
                return;
            }

            myValues.Add( node.Id );

            RaisePropertyChanged( "Values" );
        }
コード例 #9
0
        public bool TryAdd( Node node )
        {
            if( myNodes.ContainsKey( node.Id ) )
            {
                return false;
            }

            myNodes.Add( node.Id, node );

            return true;
        }
コード例 #10
0
        public Node TryAddNode( string nodeId )
        {
            var node = new Node( nodeId );

            if( !myGraph.TryAdd( node ) )
            {
                return null;
            }

            return node;
        }
コード例 #11
0
        public void Execute( Node node )
        {
            var nodesToShow = GetNodeWithSiblings( node.Id );

            var mask = new NodeMask();
            mask.Set( nodesToShow );

            var caption = myPresentation.GetPropertySetFor<Caption>().Get( node.Id );
            mask.Label = "Siblings of " + caption.DisplayText;

            var module = myPresentation.GetModule<INodeMaskModule>();
            module.Push( mask );
        }
コード例 #12
0
        public void Execute( Node node )
        {
            var nodesToHide = myPresentation.Graph.Nodes
                .Where( n => n.Id == node.Id );

            var mask = new NodeMask();
            mask.IsShowMask = false;
            mask.Set( nodesToHide );

            var caption = myPresentation.GetPropertySetFor<Caption>().Get( node.Id );
            mask.Label = caption.DisplayText;

            var module = myPresentation.GetModule<INodeMaskModule>();
            module.Push( mask );
        }
コード例 #13
0
        public void Execute( Node node )
        {
            var nodesToShow = myPresentation.Graph.Edges
                .Where( e => e.Source.Id == node.Id )
                .Select( e => e.Target )
                .ToList();

            nodesToShow.Add( node );
            var mask = new NodeMask();
            mask.Set( nodesToShow );

            var caption = myPresentation.GetPropertySetFor<Caption>().Get( node.Id );
            mask.Label = "Outgoing of " + caption.DisplayText;

            var module = myPresentation.GetModule<INodeMaskModule>();
            module.Push( mask );
        }
コード例 #14
0
        public bool Pick( Node node )
        {
            var masks = myPresentation.GetModule<INodeMaskModule>().Items
                .Where( s => s.IsApplied );

            foreach( var mask in masks )
            {
                var hitValue = mask.IsSet( node );
                if( hitValue == null )
                {
                    // this mask contains no information about the given node
                    continue;
                }

                return hitValue.Value;
            }

            // by default - if nothing else is calculated based on the masks - all nodes are visible
            return true;
        }
コード例 #15
0
 public NodeWithCaption( Node node, string displayText )
 {
     Node = node;
     DisplayText = displayText;
 }
コード例 #16
0
        public void Unset( Node node )
        {
            myValues.Remove( node.Id );

            RaisePropertyChanged( "Values" );
        }
コード例 #17
0
 public override bool? IsSet( Node node )
 {
     return IsShowMask;
 }
コード例 #18
0
 public NodeVisual( Node owner, IGraphPresentation presentation )
 {
     Owner = owner;
     myPresentation = presentation;
 }