/// <summary> /// Initializes a new instance of the <see cref="AdjacentNodesGraphBuilder{TNode,TGroup}"/> class that /// operates on the given graph. /// </summary> /// <remarks> /// The <paramref name="graph"/> will be <see cref="GraphExtensions.Clear">cleared</see> and re-built /// from the data in <see cref="NodesSource"/> and <see cref="GroupsSource"/> /// when <see cref="BuildGraph"/> is called. /// </remarks> public AdjacentNodesGraphBuilder([CanBeNull] IGraph graph = null) { graphBuilderHelper = new GraphBuilderHelper <TNode, TGroup, TNode>( graph ?? new DefaultGraph(), this.CreateNodeAndMirrorNode, this.UpdateNodeAndCreateMirrorNode, this.CreateGroupNode, this.UpdateGroupNode, this.CreateEdgeAndMirrorEdge, this.UpdateEdgeAndCreateMirrorEdge); graphBuilderHelper.EdgeCreated += (sender, args) => { var eventArgs = new GraphBuilderItemEventArgs <IEdge, object>(args.Graph, args.Item, args.SourceObject); foreach (var eventHandler in edgeCreatedHandler) { eventHandler(sender, eventArgs); } }; graphBuilderHelper.EdgeUpdated += (sender, args) => { var eventArgs = new GraphBuilderItemEventArgs <IEdge, object>(args.Graph, args.Item, args.SourceObject); foreach (var eventHandler in edgeUpdatedHandler) { eventHandler(sender, eventArgs); } }; this.graphBuilder = new AdjacencyGraphBuilder(graph); this.builderNodesSource = this.graphBuilder.CreateNodesSource <TNode>(Enumerable.Empty <TNode>()); this.builderNodesSource.NodeCreator = this.graphBuilderHelper.CreateNodeCreator(); this.builderEdgeCreator = this.graphBuilderHelper.CreateEdgeCreator(true); this.builderNodesSource.AddSuccessorsSource( dataItem => (this.successorsProvider != null ? this.successorsProvider(dataItem): null), this.builderNodesSource, this.builderEdgeCreator ); this.builderNodesSource.AddPredecessorsSource( dataItem => (this.predecessorsProvider != null ? this.predecessorsProvider(dataItem) : null), this.builderNodesSource, this.builderEdgeCreator ); this.builderNodesSource.AddSuccessorIds( dataItem => this.successorsIdProvider != null ? this.successorsIdProvider(dataItem) : null, this.builderEdgeCreator ); this.builderNodesSource.AddPredecessorIds( dataItem => this.predecessorsIdProvider != null ? this.predecessorsIdProvider(dataItem) : null, this.builderEdgeCreator ); this.builderGroupsSource = this.graphBuilder.CreateGroupNodesSource <TGroup>(Enumerable.Empty <TGroup>()); this.builderGroupsSource.NodeCreator = this.graphBuilderHelper.CreateGroupCreator(); this.mirrorGraph = new DefaultGraph(); this.nodeToMirrorNode = new Dictionary <INode, INode>(); }
/// <summary> /// Initializes a new instance of the <see cref="GraphBuilder{TNode,TGroup,TEdge}"/> class that /// operates on the given graph. /// </summary> /// <remarks> /// The <paramref name="graph"/> will be <see cref="GraphExtensions.Clear">cleared</see> and re-built /// from the data in <see cref="NodesSource"/>, <see cref="GroupsSource"/>, and <see cref="EdgesSource"/> /// when <see cref="BuildGraph"/> is called. /// </remarks> public GraphBuilder([CanBeNull] IGraph graph = null) { graphBuilderHelper = new GraphBuilderHelper <TNode, TGroup, TEdge>( graph ?? new DefaultGraph(), this.CreateNode, this.UpdateNode, this.CreateGroupNode, this.UpdateGroupNode, this.CreateEdge, this.UpdateEdge ); this.graphBuilder = new GraphBuilder(graph); this.builderNodesSource = this.graphBuilder.CreateNodesSource <TNode>(Enumerable.Empty <TNode>()); this.builderNodesSource.NodeCreator = this.graphBuilderHelper.CreateNodeCreator(); this.builderGroupsSource = this.graphBuilder.CreateGroupNodesSource <TGroup>(Enumerable.Empty <TGroup>()); this.builderGroupsSource.NodeCreator = this.graphBuilderHelper.CreateGroupCreator(); this.builderEdgesSource = this.graphBuilder.CreateEdgesSource <TEdge>(Enumerable.Empty <TEdge>(), item => this.SourceNodeProvider != null ? this.SourceNodeProvider(item) : (Provider <TEdge, object>)null, item => this.TargetNodeProvider != null ? this.TargetNodeProvider(item) : (Provider <TEdge, object>)null ); this.builderEdgesSource.EdgeCreator = this.graphBuilderHelper.CreateEdgeCreator(); }
public GraphBuilderEdgeCreator(GraphBuilderHelper <TNode, TGroup, TEdge> helper, bool labelDataFromSourceAndTarget) { this.helper = helper; this.labelDataFromSourceAndTarget = labelDataFromSourceAndTarget; }
internal GraphBuilderGroupCreator(GraphBuilderHelper <TNode, TGroup, TEdge> helper) { this.helper = helper; }