Created
December 17, 2017 12:03
-
-
Save arran4/27628c12d0abc387caa03dd6f1493629 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
var relations = []string {"", "12", "21", } | |
var nodes = []string {"AB","BC","CA",} | |
func main() { | |
fmt.Printf("digraph causeeffect {\n") | |
i := 0 | |
for _, r1 := range relations { | |
for _, r2 := range relations { | |
for _, r3 := range relations { | |
fmt.Printf("subgraph cluster_%d {\n", i ) | |
switch r1 { | |
case "12": | |
fmt.Printf(" %s%d -> %s%d;\n", "A", i, "B", i) | |
case "21": | |
fmt.Printf(" %s%d -> %s%d;\n", "B", i, "A", i) | |
case "": | |
fmt.Printf(" %s%d;\n %s%d;\n", "B", i, "A", i) | |
} | |
switch r2 { | |
case "12": | |
fmt.Printf(" %s%d -> %s%d;\n", "A", i, "C", i) | |
case "21": | |
fmt.Printf(" %s%d -> %s%d;\n", "C", i, "A", i) | |
case "": | |
fmt.Printf(" %s%d;\n %s%d;\n", "A", i, "C", i) | |
} | |
switch r3 { | |
case "12": | |
fmt.Printf(" %s%d -> %s%d;\n", "C", i, "B", i) | |
case "21": | |
fmt.Printf(" %s%d -> %s%d;\n", "B", i, "C", i) | |
case "": | |
fmt.Printf(" %s%d;\n %s%d;\n", "B", i, "C", i) | |
} | |
i++ | |
fmt.Printf(" label=\"Premutation %d\";\n", i) | |
fmt.Printf(" graph[style=dotted];\n") | |
fmt.Printf("}\n") | |
} | |
} | |
} | |
fmt.Printf("}") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment