selectFullGraphNodes returns the structural nodes to draw: tags are excluded (they are keyword glue that turns the view into a hairball). When the graph is small all remaining nodes show; otherwise only the top hubs, so a big graph renders a readable backbone.
(g *knowledge.Graph)
| 85 | // small all remaining nodes show; otherwise only the top hubs, so a big graph |
| 86 | // renders a readable backbone. |
| 87 | func selectFullGraphNodes(g *knowledge.Graph) map[string]bool { |
| 88 | include := make(map[string]bool) |
| 89 | if g.Len() <= graphVizMaxNodes { |
| 90 | for _, n := range g.Nodes() { |
| 91 | if n.Kind == knowledge.KindTag { |
| 92 | continue |
| 93 | } |
| 94 | include[n.ID] = true |
| 95 | } |
| 96 | return include |
| 97 | } |
| 98 | // Pull extra hubs since some will be tags we skip. |
| 99 | for _, h := range g.Hubs(graphVizMaxNodes * 2) { |
| 100 | if h.Kind == knowledge.KindTag { |
| 101 | continue |
| 102 | } |
| 103 | include[h.ID] = true |
| 104 | if len(include) >= graphVizMaxNodes { |
| 105 | break |
| 106 | } |
| 107 | } |
| 108 | return include |
| 109 | } |
| 110 | |
| 111 | // graphToDOT renders the included nodes and the edges among them as undirected |
| 112 | // DOT for a force-directed layout: a solid dark canvas with light, wrapped |