ForceDirectedGraph<T>.generateNTree constructor
ForceDirectedGraph<T>.generateNTree ({
- required int nodeCount,
- required int maxDepth,
- required int n,
- required T generator(),
- GraphConfig config = const GraphConfig(),
Generate a random tree graph.
nodeCount is the max node count.
maxDepth is the max depth of the tree.
n is the max children count of a node.
generator is the generator of the node data. Make sure the data is unique.
Implementation
ForceDirectedGraph.generateNTree({
required int nodeCount,
required int maxDepth,
required int n,
required T Function() generator,
this.config = const GraphConfig(),
}) {
Random random = Random();
final root = Node(generator());
nodes.add(root);
_createNTree(root, nodeCount - 1, maxDepth - 1, n, random, generator);
}