private void AddEdge(EdgeFamily edgeFamily, Identifier identifier) { var source = NodeIdentifier(edgeFamily.Source, identifier, $"Cannot identify source node for edge family {edgeFamily.Name}"); var target = NodeIdentifier(edgeFamily.Target, identifier, $"Cannot identify target node for edge family {edgeFamily.Name}"); var sourceNode = _graph.FindNode(source.Id()); var targetNode = _graph.FindNode(target.Id()); if (targetNode == null) { throw new GraphRenderException($"Target node {source.Id()} does not exist"); } if (sourceNode == null) { throw new GraphRenderException($"Source node {source.Id()} does not exist"); } var edge = _graph.AddEdge(source.Id(), target.Id()); _edges[identifier] = edge; edge.Attr.ArrowheadAtTarget = ArrowStyle.None; }
private void CreateConfig() { NodeFamily nodes = new NodeFamily( new List <IdentifierPartTemplate>() { new IdentifierPartTemplate("v", "0", "n") } ); EdgeFamily edges = new EdgeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("a", "0", "n"), new IdentifierPartTemplate("b", "0", "n"), new IdentifierPartTemplate("x", "0", "n") }, new EdgeFamily.EdgeEnd(nodes, new List <string> { "__a__" }), new EdgeFamily.EdgeEnd(nodes, new List <string> { "__b__" }) ) { ValidationTemplate = "g[__a__][__x__] == __b__", IsDirected = true }; _config = new GraphConfig { Edges = new HashSet <EdgeFamily> { edges }, Nodes = new HashSet <NodeFamily> { nodes } }; }
public void CreateGraphConfigForDfs() { NodeFamily nodes = new NodeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("v", "0", "n") }); var dfsNode = System.Tuple.Create( new Condition("\"__CURRENT_FUNCTION__\" == \"dfs\" && __ARG1__ == __v__"), (INodeProperty) new FillColorNodeProperty(Color.Red)); nodes.Properties.Add(dfsNode); EdgeFamily edges = new EdgeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("a", "0", "n"), new IdentifierPartTemplate("b", "0", "n"), new IdentifierPartTemplate("x", "0", "g[__a__].size()") }, new EdgeFamily.EdgeEnd(nodes, new List <string> { "__a__" }), new EdgeFamily.EdgeEnd(nodes, new List <string> { "__b__" })) { ValidationTemplate = "__a__ < __b__ && g[__a__][__x__] == __b__" }; var dfsEdges = Tuple.Create(new Condition("p[__a__] == __b__ || p[__b__] == __a__"), (IEdgeProperty) new LineColorEdgeProperty(Color.Red)); edges.Properties.Add(dfsEdges); GraphConfig config = new GraphConfig { Edges = new HashSet <EdgeFamily> { edges }, Nodes = new HashSet <NodeFamily> { nodes } }; }
public void FromEdgeFamily(EdgeFamily edgeFamily) { IdentifierPartRangeControl.FromRanges(edgeFamily.Ranges); validationTemplateBox.Text = edgeFamily.ValidationTemplate; FamilyName.Text = edgeFamily.Name; SetNodeFamilies(edgeFamily.Target.NodeFamilyName, edgeFamily.Source.NodeFamilyName); _targetWindow = new EdgeEndControl(edgeFamily.Target); _sourceWindow = new EdgeEndControl(edgeFamily.Source); _targetWindow.EdgeEndIdParts.ForEach(x => Debug.WriteLine($"{x.IdPart}, {x.Template}")); var windows = new List <Window>(); foreach (var conditionalProperty in edgeFamily.ConditionalProperties) { var window = new EdgeConditionalPropertyWindow(); window.FromConditionalProperty(conditionalProperty); windows.Add(window); } PropertiesControl.SetNewWindows(windows); }
private void AddEdge(EdgeFamily edgeFamily, Identifier identifier) { //TODO check IsValidValue var source = NodeIdentifier(edgeFamily.Source, identifier).Id(); var target = NodeIdentifier(edgeFamily.Target, identifier).Id(); var sourceNode = _graph.FindNode(source); var targetNode = _graph.FindNode(target); if (targetNode == null || sourceNode == null) { //TODO more specific exception throw new SystemException("Target or source nodes do not exist"); } var edge = _graph.AddEdge(source, target); _edges[identifier.Id()] = edge; if (!edgeFamily.IsDirected) { edge.Attr.ArrowheadAtTarget = ArrowStyle.None; } }