private void ProcessNodeConnections(GraphvizTableRow row, GraphvizNode node) { if (ConnIndex <= 0) { return; } string connections = row[ConnIndex].Value; if (string.IsNullOrEmpty(connections)) { return; } var nodes = connections.Split(new string[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (var n in nodes) { string dest = n.Trim(); if (!string.IsNullOrEmpty(dest)) { AddEdgeIfNotExist(node.Name, dest, GraphvizEdge.EdgeDir.Normal); } } }
private void ProcessNode(GraphvizTableRow row) { GraphvizNode node = AddNodeIfNotExist(row[0].Value); ProcessNodeAttributes(row, node); ProcessNodeConnections(row, node); }
public void Add(GraphvizTableRow row) { if (row != null) { Rows.Add(row); } }
private void ProcessEdge(GraphvizTableRow row) { string edges = row[0].Value; GraphvizEdge.EdgeDir dir = ToDir(edges); var nodes = edges.Split(new string[] { "<->", "->", "--" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < nodes.Length - 1; i++) { string from = nodes[i].Trim(); string to = nodes[i + 1].Trim(); if (!string.IsNullOrEmpty(from) && !string.IsNullOrEmpty(to)) { GraphvizEdge edge = AddEdgeIfNotExist(from, to, dir); ProcessEdgeAttributes(row, edge); } } }
private static GraphvizTableRow ToRow(string tableRow) { GraphvizTableRow row = new GraphvizTableRow(); if (!IsTableRow(tableRow)) { return(row); } var cells = tableRow.Split('|'); for (int i = 1; i < cells.Length - 1; i++) { // create cells except first and last empty string row.Add(new GraphvizTableCell(cells[i].Trim())); } return(row); }
private void ProcessEdgeAttributes(GraphvizTableRow row, GraphvizEdge edge) { if (LabelIndex >= 0) { string label = row[LabelIndex]?.Value; edge.Label = label?.Trim(); } if (ColorIndex >= 0) { string color = row[ColorIndex]?.Value; edge.Color = color?.Trim(); } if (ShapeIndex >= 0) { string shape = row[ShapeIndex]?.Value; edge.ArrowHead = shape?.Trim(); } }
private void ProcessNodeAttributes(GraphvizTableRow row, GraphvizNode node) { if (LabelIndex >= 0) { string label = row[LabelIndex]?.Value; node.Label = label?.Trim(); } if (ShapeIndex >= 0) { string shape = row[ShapeIndex]?.Value; node.Shape = shape?.Trim(); } if (ColorIndex >= 0) { string color = row[ColorIndex]?.Value; node.FillColor = color?.Trim(); } }
private string MakeGraphvizDotContent(GraphvizTable table) { if ((table == null) || (table.RowCount < 2)) { return(null); } GraphvizTableRow header = table[0]; ShapeIndex = header.Index("Shape"); LabelIndex = header.Index("Label"); ConnIndex = header.Index("Connections"); ColorIndex = header.Index("Color"); for (int i = 1; i < table.RowCount; i++) { GraphvizTableRow row = table[i]; bool? isNode = row[0].IsDotNode(); if (!isNode.HasValue) { return(null); } if (isNode.Value) { if (row[0].Value.Contains(":")) { DotModel.Add(new GraphvizRankNode(row[0].Value)); } else { ProcessNode(row); } } else { ProcessEdge(row); } } return(DotModel.GetDotString()); }