You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a graph, and I want to set some nodes to be on the far left, some to be on the far right, and the rest can be anywhere in the middle. I have found some code that does what I want in the dot format directly, but I am not sure how to implement this using this package:
digraphG {
rankdir = LR;
A -> B;
A -> C -> D;
X -> Y;
{ rank=min; A; X; } // These two lines do what I want
{ rank=max; B; D; Y; }
}
I have already got all of the code to create and connect the nodes and render them, but I just need what will probably be the two lines of code to do the laying out.
The text was updated successfully, but these errors were encountered:
I have a graph, and I want to set some nodes to be on the far left, some to be on the far right, and the rest can be anywhere in the middle. I have found some code that does what I want in the dot format directly, but I am not sure how to implement this using this package:
digraphG {
rankdir = LR;
A -> B;
A -> C -> D;
X -> Y;
{ rank=min; A; X; } // These two lines do what I want
{ rank=max; B; D; Y; }
}
I have already got all of the code to create and connect the nodes and render them, but I just need what will probably be the two lines of code to do the laying out.
Hi, try this~
funcCreateGraph() (string, error) {
g:=graphviz.New()
graph, err:=g.Graph()
iferr!=nil {
return"", err
}
deferfunc() {
_=graph.Close()
_=g.Close()
}()
graph.SetRankDir(cgraph.TBRank)
s1:=graph.SubGraph("rax", 1)
s1.SafeSet(string(gographviz.Rank), "same", "")
a, _:=graph.CreateNode("A")
b, _:=graph.CreateNode("B")
c, _:=s1.CreateNode("C")
d, _:=graph.CreateNode("D")
x, _:=s1.CreateNode("X")
y, _:=graph.CreateNode("Y")
_, _=graph.CreateEdge("ab", a, b)
_, _=graph.CreateEdge("ac", a, c)
_, _=graph.CreateEdge("cd", c, d)
_, _=graph.CreateEdge("xy", x, y)
err=g.RenderFilename(graph, graphviz.XDOT, "test.dot")
data, _:=os.ReadFile("test.dot")
fmt.Println(string(data))
return"", err
}
I have a graph, and I want to set some nodes to be on the far left, some to be on the far right, and the rest can be anywhere in the middle. I have found some code that does what I want in the dot format directly, but I am not sure how to implement this using this package:
I have already got all of the code to create and connect the nodes and render them, but I just need what will probably be the two lines of code to do the laying out.
The text was updated successfully, but these errors were encountered: