### Implement Layout Algorithms Source: https://pub.dev/documentation/graphview/latest/index.html Examples of different layout algorithms available for GraphView. ```dart GraphView.builder( graph: graph, algorithm: BalloonLayoutAlgorithm( BuchheimWalkerConfiguration(), null ), builder: (node) => nodeWidget(node), ) ``` ```dart GraphView.builder( graph: graph, algorithm: CircleLayoutAlgorithm( CircleLayoutConfiguration( radius: 200.0, reduceEdgeCrossing: true, ), null ), builder: (node) => nodeWidget(node), ) ``` ```dart GraphView.builder( graph: graph, algorithm: RadialTreeLayoutAlgorithm( BuchheimWalkerConfiguration(), null ), builder: (node) => nodeWidget(node), ) ``` ```dart GraphView.builder( graph: graph, algorithm: TidierTreeLayoutAlgorithm( BuchheimWalkerConfiguration(), TreeEdgeRenderer(config) ), builder: (node) => nodeWidget(node), ) ``` ```dart GraphView.builder( graph: graph, algorithm: MindmapAlgorithm( BuchheimWalkerConfiguration(), MindmapEdgeRenderer(config) ), builder: (node) => nodeWidget(node), ) ``` -------------------------------- ### Initialize Path Object Source: https://pub.dev/documentation/graphview/latest/graphview/TreeEdgeRenderer/linePath.html Instantiate a new Path object. This is a basic setup for using Path functionalities. ```javascript var linePath = Path(); ``` -------------------------------- ### Initialize Path with trianglePath Source: https://pub.dev/documentation/graphview/latest/graphview/ArrowEdgeRenderer/trianglePath.html Initializes a new Path object and assigns it to the trianglePath variable. This is a basic setup for using the trianglePath functionality. ```javascript var trianglePath = Path(); ``` -------------------------------- ### Initialize successorNodes List Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerNodeData/successorNodes.html Initializes an empty list for successor nodes. This is a common setup for managing node relationships. ```java List successorNodes = []; ``` -------------------------------- ### Example createState Implementation Source: https://pub.dev/documentation/graphview/latest/graphview/GraphViewCustomPainter/createState.html Subclasses should override this method to return a newly created instance of their associated State subclass. The framework can call this method multiple times. ```dart @override State createState() => _SomeWidgetState(); ``` -------------------------------- ### Get nodeAnimationController Source: https://pub.dev/documentation/graphview/latest/graphview/RenderCustomLayoutBox/nodeAnimationController.html Retrieves the current AnimationController. No setup required. ```dart AnimationController get nodeAnimationController => _nodeAnimationController; ``` -------------------------------- ### void init(Graph? graph) Source: https://pub.dev/documentation/graphview/latest/graphview/EiglspergerAlgorithm/init.html Initializes the graph by copying the input graph and executing the layout algorithm pipeline. ```APIDOC ## void init(Graph? graph) ### Description Initializes the graph structure by creating a copy of the provided graph and executing the internal layout pipeline including cycle removal, layer assignment, node ordering, and coordinate assignment. ### Parameters #### Parameters - **graph** (Graph?) - Required - The graph object to be initialized. ### Implementation ```dart @override void init(Graph? graph) { this.graph = copyGraph(graph!); reset(); initNodeData(); cycleRemoval(); layerAssignment(); nodeOrdering(); coordinateAssignment(); denormalize(); restoreCycle(); } ``` ``` -------------------------------- ### Create Empty ContainerX Instance Source: https://pub.dev/documentation/graphview/latest/graphview/ContainerX/createEmpty.html Use this static method to create a new, empty instance of ContainerX. No specific setup or imports are required beyond the class definition. ```dart static ContainerX createEmpty() => ContainerX(); ``` -------------------------------- ### Retrieve Subtree Separation Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerConfiguration/getSubtreeSeparation.html Use this method to get the current value of subtreeSeparation. No setup is required. ```java int getSubtreeSeparation() { return subtreeSeparation; } ``` -------------------------------- ### startLayout abstract method Source: https://pub.dev/documentation/graphview/latest/graphview/GraphChildManager/startLayout.html Documentation for the startLayout abstract method used in the GraphView project. ```APIDOC ## startLayout ### Description An abstract method used to initiate the layout process for the graph view. ### Method N/A (Abstract Method) ### Signature void startLayout() ``` -------------------------------- ### Get Sibling Separation Value Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerConfiguration/getSiblingSeparation.html Use this method to retrieve the current sibling separation value. No specific setup or imports are required beyond the class definition. ```java int getSiblingSeparation() { return siblingSeparation; } ``` -------------------------------- ### Get Graph View Orientation Source: https://pub.dev/documentation/graphview/latest/graphview/SugiyamaConfiguration/getOrientation.html Use this method to retrieve the current orientation setting of the graph view. No specific setup is required beyond having an instance of the graph view. ```java int getOrientation() { return orientation; } ``` -------------------------------- ### init abstract method Source: https://pub.dev/documentation/graphview/latest/graphview/Algorithm/init.html Initializes the GraphView with an optional graph object. ```APIDOC ## void init(Graph? graph) ### Description Initializes the GraphView with an optional graph object. ### Method void ### Endpoint N/A (Method signature) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (void) This method does not return a value. #### Response Example None ``` -------------------------------- ### init method Source: https://pub.dev/documentation/graphview/latest/graphview/BalloonLayoutAlgorithm/init.html Initializes the GraphView with an optional Graph object. ```APIDOC ## init method ### Description Initializes the GraphView component. It accepts an optional `Graph` object to set up the initial state. ### Method `init` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **graph** (Graph?) - Optional - The initial graph object to load. ### Request Example ```json { "graph": null } ``` ### Response #### Success Response (200) - **void** - This method does not return a value. #### Response Example ```json // No response body for void methods ``` ## Implementation ```dart @override void init(Graph? graph) { // Implementation can be added if needed } ``` ``` -------------------------------- ### Retrieve Level Separation Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerConfiguration/getLevelSeparation.html Use this method to get the current separation value between levels in the graph. No specific setup is required beyond having an instance of the class containing this method. ```java int getLevelSeparation() { return levelSeparation; } ``` -------------------------------- ### Get Node Position Implementation Source: https://pub.dev/documentation/graphview/latest/graphview/EdgeRenderer/getNodePosition.html Retrieves the animated position of a node if available, otherwise returns the node's default position. Use this to get the current visual position of a node. ```dart Offset getNodePosition(Node node) => _animatedPositions?[node] ?? node.position; ``` -------------------------------- ### Initialize ContainerX Source: https://pub.dev/documentation/graphview/latest/graphview/ContainerX/ContainerX.html Standard constructor for creating a new instance of ContainerX. ```dart ContainerX(); ``` -------------------------------- ### GET /delegate Source: https://pub.dev/documentation/graphview/latest/graphview/RenderCustomLayoutBox/delegate.html Retrieves the current GraphChildDelegate instance. ```APIDOC ## GET /delegate ### Description Retrieves the current GraphChildDelegate instance associated with the component. ### Method GET ### Response - **delegate** (GraphChildDelegate) - The current delegate instance. ``` -------------------------------- ### Initialize MindmapAlgorithm Source: https://pub.dev/documentation/graphview/latest/graphview/MindmapAlgorithm/MindmapAlgorithm.html Constructs a new MindmapAlgorithm instance using the provided configuration and optional renderer. ```dart MindmapAlgorithm(BuchheimWalkerConfiguration config, EdgeRenderer? renderer) : super(config, renderer ?? MindmapEdgeRenderer(config)); ``` -------------------------------- ### Get delegate property Source: https://pub.dev/documentation/graphview/latest/graphview/RenderCustomLayoutBox/delegate.html Retrieves the current GraphChildDelegate instance. ```dart GraphChildDelegate get delegate => _delegate; ``` -------------------------------- ### SugiyamaAlgorithm Constructors and Properties Source: https://pub.dev/documentation/graphview/latest/graphview/SugiyamaAlgorithm-class.html Configuration and state management for the Sugiyama algorithm. ```APIDOC ## SugiyamaAlgorithm(SugiyamaConfiguration configuration) ### Description Initializes the algorithm with a specific configuration. ### Properties - **configuration** (SugiyamaConfiguration) - The configuration settings for the algorithm. - **graph** (Graph) - The graph instance being processed. - **layers** (List>) - The current layer assignment of nodes. - **nodeData** (Map) - Data associated with nodes for the algorithm. ``` -------------------------------- ### GET edges Source: https://pub.dev/documentation/graphview/latest/graphview/Graph/edges.html Retrieves the list of edges associated with the graph. ```APIDOC ## GET edges ### Description Retrieves the current list of Edge objects defined in the graph. ### Method GET ### Endpoint edges ### Response #### Success Response (200) - **edges** (List) - A list of Edge objects representing the connections in the graph. ``` -------------------------------- ### EiglspergerAlgorithm Constructor Source: https://pub.dev/documentation/graphview/latest/graphview/EiglspergerAlgorithm/EiglspergerAlgorithm.html Initializes a new instance of the EiglspergerAlgorithm class using the provided configuration. ```APIDOC ## Constructor: EiglspergerAlgorithm ### Description Creates a new instance of the EiglspergerAlgorithm class. ### Parameters #### Required Parameters - **configuration** (SugiyamaConfiguration) - Required - The configuration object used to define the algorithm's behavior. ### Implementation ```dart EiglspergerAlgorithm(this.configuration) { // renderer = SugiyamaEdgeRenderer(nodeData, edgeData, configuration.bendPointShape, configuration.addTriangleToEdge); } ``` ``` -------------------------------- ### y property accessors Source: https://pub.dev/documentation/graphview/latest/graphview/Node/y.html Methods to get and set the vertical position (y) of the component. ```APIDOC ## GET y ### Description Retrieves the current vertical coordinate from the position offset. ### Implementation ```dart double get y => position.dy; ``` ## SET y ### Description Updates the vertical coordinate of the position offset while preserving the horizontal coordinate. ### Parameters - **value** (double) - Required - The new vertical position value. ### Implementation ```dart set y(double value) { position = Offset(position.dx, value); } ``` ``` -------------------------------- ### Get Y Property Source: https://pub.dev/documentation/graphview/latest/graphview/Node/y.html Retrieves the current y-coordinate of the position. This is a read-only getter. ```dart double get y => position.dy; ``` -------------------------------- ### SugiyamaAlgorithm Constructor Source: https://pub.dev/documentation/graphview/latest/graphview/SugiyamaAlgorithm/SugiyamaAlgorithm.html Initializes a new instance of the SugiyamaAlgorithm class with the specified configuration. ```APIDOC ## SugiyamaAlgorithm Constructor ### Description Initializes a new instance of the SugiyamaAlgorithm class. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **configuration** (SugiyamaConfiguration) - Required - The configuration object for the Sugiyama algorithm. ### Implementation Details Upon initialization, a `SugiyamaEdgeRenderer` is created using the provided node data, edge data, and bend point shape from the configuration. The `addTriangleToEdge` setting from the configuration is also passed to the renderer. ### Request Example ```dart final config = SugiyamaConfiguration(...); final algorithm = SugiyamaAlgorithm(config); ``` ### Response #### Success Response (200) N/A (Constructor) #### Response Example N/A (Constructor) ``` -------------------------------- ### GET width property Source: https://pub.dev/documentation/graphview/latest/graphview/Node/width.html Retrieves the width value from the size object. ```APIDOC ## GET width ### Description Returns the width dimension of the current size object. ### Method GET ### Endpoint width ### Response #### Success Response (200) - **width** (double) - The width value derived from size.width. ``` -------------------------------- ### Initialize and Configure GraphView Source: https://pub.dev/documentation/graphview/latest/index.html Sets up a basic Flutter application with a GraphView widget, including interactive configuration for layout parameters and dynamic node addition. ```dart void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) => MaterialApp( home: TreeViewPage(), ); } class TreeViewPage extends StatefulWidget { @override _TreeViewPageState createState() => _TreeViewPageState(); } class _TreeViewPageState extends State { final GraphViewController controller = GraphViewController(); @override Widget build(BuildContext context) { return Scaffold( body: Column( mainAxisSize: MainAxisSize.max, children: [ Wrap( children: [ Container( width: 100, child: TextFormField( initialValue: builder.siblingSeparation.toString(), decoration: InputDecoration(labelText: "Sibling Separation"), onChanged: (text) { builder.siblingSeparation = int.tryParse(text) ?? 100; this.setState(() {}); }, ), ), Container( width: 100, child: TextFormField( initialValue: builder.levelSeparation.toString(), decoration: InputDecoration(labelText: "Level Separation"), onChanged: (text) { builder.levelSeparation = int.tryParse(text) ?? 100; this.setState(() {}); }, ), ), Container( width: 100, child: TextFormField( initialValue: builder.subtreeSeparation.toString(), decoration: InputDecoration(labelText: "Subtree separation"), onChanged: (text) { builder.subtreeSeparation = int.tryParse(text) ?? 100; this.setState(() {}); }, ), ), Container( width: 100, child: TextFormField( initialValue: builder.orientation.toString(), decoration: InputDecoration(labelText: "Orientation"), onChanged: (text) { builder.orientation = int.tryParse(text) ?? 100; this.setState(() {}); }, ), ), ElevatedButton( onPressed: () { final node12 = Node.Id(r.nextInt(100)); var edge = graph.getNodeAtPosition(r.nextInt(graph.nodeCount())); print(edge); graph.addEdge(edge, node12); setState(() {}); }, child: Text("Add"), ) ], ), Expanded( child: GraphView.builder( graph: graph, algorithm: BuchheimWalkerAlgorithm(builder, TreeEdgeRenderer(builder)), controller: controller, animated: true, autoZoomToFit: true, builder: (Node node) { // I can decide what widget should be shown here based on the id var a = node.key.value as int; return rectangleWidget(a); }, ), ), ], )); } Random r = Random(); Widget rectangleWidget(int a) { return InkWell( onTap: () { print('clicked'); }, child: Container( padding: EdgeInsets.all(16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), boxShadow: [ BoxShadow(color: Colors.blue[100], spreadRadius: 1), ], ), child: Text('Node ${a}')), ); } final Graph graph = Graph()..isTree = true; BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration(); @override void initState() { final node1 = Node.Id(1); final node2 = Node.Id(2); final node3 = Node.Id(3); final node4 = Node.Id(4); final node5 = Node.Id(5); final node6 = Node.Id(6); final node8 = Node.Id(7); final node7 = Node.Id(8); final node9 = Node.Id(9); final node10 = Node.Id(10); final node11 = Node.Id(11); final node12 = Node.Id(12); graph.addEdge(node1, node2); graph.addEdge(node1, node3, paint: Paint()..color = Colors.red); graph.addEdge(node1, node4, paint: Paint()..color = Colors.blue); graph.addEdge(node2, node5); graph.addEdge(node2, node6); graph.addEdge(node6, node7, paint: Paint()..color = Colors.red); graph.addEdge(node6, node8, paint: Paint()..color = Colors.red); graph.addEdge(node4, node9); ``` -------------------------------- ### RenderCustomLayoutBox Constructor Source: https://pub.dev/documentation/graphview/latest/graphview/RenderCustomLayoutBox/RenderCustomLayoutBox.html Initializes a new instance of RenderCustomLayoutBox with the required delegate, paint settings, animation state, and controller. ```APIDOC ## RenderCustomLayoutBox Constructor ### Description Initializes a new RenderCustomLayoutBox instance to manage graph layout rendering and animations. ### Parameters - **delegate** (GraphChildDelegate) - Required - The delegate responsible for graph child layout logic. - **paint** (Paint?) - Optional - The paint object used for rendering edges. - **enableAnimation** (bool) - Required - Flag to toggle animation support. - **nodeAnimationController** (AnimationController) - Required - The controller managing node animations. - **childManager** (GraphChildManager?) - Optional - The manager responsible for handling child nodes. ### Implementation ```dart RenderCustomLayoutBox( GraphChildDelegate delegate, Paint? paint, bool enableAnimation, { required AnimationController nodeAnimationController, this.childManager, }) { _nodeAnimationController = nodeAnimationController; _delegate = delegate; edgePaint = paint; this.enableAnimation = enableAnimation; } ``` ``` -------------------------------- ### GET height property Source: https://pub.dev/documentation/graphview/latest/graphview/Node/height.html Retrieves the height value from the size object. ```APIDOC ## GET height ### Description Returns the height of the current size object as a double. ### Method GET ### Endpoint height ### Response - **height** (double) - The height value of the size object. ``` -------------------------------- ### GraphViewController Class Overview Source: https://pub.dev/documentation/graphview/latest/graphview/GraphViewController-class.html Overview of the GraphViewController class, including its constructor, properties, and methods. ```APIDOC ## GraphViewController Class ### Description Manages the visualization and interaction of a graph, including node collapsing, expanding, and focusing. ### Constructor #### GraphViewController({TransformationController? transformationController}) Initializes a new instance of the GraphViewController. ### Properties - **collapsedNode** (Node?): Getter/setter for the currently collapsed node. - **collapsedNodes** (Map): A final map tracking collapsed nodes. - **expandingNodes** (Map): A final map tracking nodes currently being expanded. - **focusedNode** (Node?): Getter/setter for the currently focused node. - **hashCode** (int): The hash code for this object. - **hiddenBy** (Map): A final map tracking nodes hidden by other nodes. - **runtimeType** (Type): A representation of the runtime type of the object. - **transformationController** (TransformationController?): A final transformation controller associated with the view. ### Methods - **animateToMatrix(Matrix4 target)**: Animates the view to a target matrix. - **animateToNode(ValueKey key)**: Animates the view to focus on a specific node identified by its key. - **collapseNode(Graph graph, Node node, {dynamic animate = false})**: Collapses a given node in the graph. The `animate` parameter controls whether the collapse is animated. - **expandNode(Graph graph, Node node, {dynamic animate = false})**: Expands a given node in the graph. The `animate` parameter controls whether the expansion is animated. - **findClosestVisibleAncestor(Graph graph, Node node)**: Finds the closest visible ancestor node for a given node. - **forceRecalculation()**: Forces a recalculation of the graph layout or view state. - **getCollapsingEdges(Graph graph)**: Retrieves a list of edges that are currently collapsing. - **getExpandingEdges(Graph graph)**: Retrieves a list of edges that are currently expanding. - **isNodeCollapsed(Node node)**: Checks if a given node is currently collapsed. - **isNodeExpanding(Node node)**: Checks if a given node is currently expanding. - **isNodeHidden(Node node)**: Checks if a given node is currently hidden. - **isNodeVisible(Graph graph, Node node)**: Checks if a given node is visible within the graph. - **jumpToFocusedNode()**: Immediately moves the view to the focused node. - **jumpToNode(ValueKey key)**: Immediately moves the view to a node identified by its key. - **noSuchMethod(Invocation invocation)**: Invoked when a nonexistent method or property is accessed. - **removeCollapsingNodes()**: Removes nodes that are currently in the process of collapsing. - **resetView()**: Resets the graph view to its default state. - **setInitiallyCollapsedByKeys(Graph graph, Set keys)**: Sets a set of nodes to be initially collapsed, identified by their keys. - **setInitiallyCollapsedNodes(Graph graph, List nodes)**: Sets a list of nodes to be initially collapsed. - **toggleNodeExpanded(Graph graph, Node node, {dynamic animate = false})**: Toggles the expanded state of a given node. The `animate` parameter controls whether the toggle is animated. - **toString()**: Returns a string representation of the object. - **zoomToFit()**: Zooms the view to fit the entire graph. ### Operators - **operator ==(Object other)**: Checks for equality with another object. ``` -------------------------------- ### GET size() Source: https://pub.dev/documentation/graphview/latest/graphview/NodeCluster/size.html Retrieves the total number of nodes currently present in the graph. ```APIDOC ## size() ### Description Returns the total count of nodes in the graph. ### Method GET ### Response - **size** (int) - The number of nodes in the graph. ### Implementation ```dart int size() { return nodes.length; } ``` ``` -------------------------------- ### GET /x Source: https://pub.dev/documentation/graphview/latest/graphview/Node/x.html Retrieves the current horizontal position (x) from the position object. ```APIDOC ## GET /x ### Description Returns the current horizontal coordinate (dx) from the position property. ### Implementation ```dart double get x => position.dx; ``` ``` -------------------------------- ### Implement startLayout Method Source: https://pub.dev/documentation/graphview/latest/graphview/GraphViewElement/startLayout.html This method is called to begin the layout process. It asserts that layout is not already in progress and resets internal maps for node-to-element and key-to-element mappings. ```dart @override void startLayout() { assert(!_debugIsDoingLayout); _newNodeToElement = {}; _newKeyToElement = {}; } ``` -------------------------------- ### Get x property Source: https://pub.dev/documentation/graphview/latest/graphview/Node/x.html Retrieves the current horizontal coordinate from the position offset. ```dart double get x => position.dx; ``` -------------------------------- ### Initialize SugiyamaAlgorithm Source: https://pub.dev/documentation/graphview/latest/graphview/SugiyamaAlgorithm/SugiyamaAlgorithm.html Constructs the algorithm instance using the provided configuration. This initializes the internal SugiyamaEdgeRenderer with node and edge data. ```dart SugiyamaAlgorithm(this.configuration) { renderer = SugiyamaEdgeRenderer(nodeData, edgeData, configuration.bendPointShape, configuration.addTriangleToEdge); } ``` -------------------------------- ### Get Height Property Source: https://pub.dev/documentation/graphview/latest/graphview/Node/height.html Retrieves the current height of the GraphView. This is a read-only property. ```dart double get height => size.height; ``` -------------------------------- ### ContainerX Class Overview Source: https://pub.dev/documentation/graphview/latest/graphview/ContainerX-class.html Overview of the ContainerX class properties and methods. ```APIDOC ## ContainerX Class ### Properties - **index** (int) - Getter/Setter for the index. - **isEmpty** (bool) - Indicates if the container is empty. - **measure** (double) - Getter/Setter for the measure value. - **pos** (int) - Getter/Setter for the position. - **segments** (List) - Getter/Setter for the list of segments. ### Methods - **append(Segment segment)** - Appends a segment to the container. - **contains(Segment segment)** - Checks if the container contains a specific segment. - **join(ContainerX other)** - Joins another ContainerX into this one. - **size()** - Returns the size of the container. ### Static Methods - **createEmpty()** - Returns a new empty ContainerX. - **split(ContainerX container, Segment key)** - Splits a container based on a segment key, returning a ContainerPair. - **splitAt(ContainerX container, int position)** - Splits a container at a specific position, returning a ContainerPair. ``` -------------------------------- ### Configuration Properties Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerConfiguration-class.html Properties available to get or set the layout configuration values. ```APIDOC ## Properties - **levelSeparation** (int) - The vertical or horizontal distance between tree levels. - **orientation** (int) - The layout direction (e.g., ORIENTATION_TOP_BOTTOM). - **siblingSeparation** (int) - The distance between sibling nodes. - **subtreeSeparation** (int) - The distance between distinct subtrees. - **useCurvedConnections** (bool) - Toggle for rendering curved lines between nodes. ``` -------------------------------- ### GraphView Constructor Implementation Source: https://pub.dev/documentation/graphview/latest/graphview/GraphView/GraphView.html Shows the implementation of the GraphView constructor, initializing the graph, algorithm, builder, and other properties. ```dart GraphView({ Key? key, required this.graph, required this.algorithm, this.paint, required this.builder, this.animated = true, this.controller, this.toggleAnimationDuration, this.centerGraph = false, }) : _isBuilder = false, delegate = GraphChildDelegate( graph: graph, algorithm: algorithm, builder: builder, controller: null), super(key: key); ``` -------------------------------- ### init method Source: https://pub.dev/documentation/graphview/latest/graphview/FruchtermanReingoldAlgorithm/init.html Initializes the GraphView by processing nodes and setting their initial positions and rectangles. It supports shuffling nodes if configured. ```APIDOC ## init method ### Description Initializes the GraphView by processing nodes and setting their initial positions and rectangles. It supports shuffling nodes if configured. ### Method void ### Parameters #### Path Parameters - **graph** (Graph?) - Optional - The graph object containing nodes to be initialized. ### Request Example ```json { "graph": { "nodes": [ { "id": "node1", "x": 10, "y": 10, "width": 50, "height": 30, "position": {"dx": 0, "dy": 0} } ] } } ``` ### Response This method does not return a value. It modifies the internal state of the GraphView. ### Response Example ```json // No direct response body, internal state is updated. ``` ### Implementation Details ```dart @override void init(Graph? graph) { graph!.nodes.forEach((node) { displacement[node] = Offset.zero; nodeRects[node] = Rect.fromLTWH(node.x, node.y, node.width, node.height); if (configuration.shuffleNodes) { node.position = Offset( rand.nextDouble() * graphWidth, rand.nextDouble() * graphHeight); // Update cached rect after position change nodeRects[node] = Rect.fromLTWH(node.x, node.y, node.width, node.height); } }); } ``` ``` -------------------------------- ### Declare SugiyamaConfiguration Source: https://pub.dev/documentation/graphview/latest/graphview/EiglspergerAlgorithm/configuration.html Declare an instance of SugiyamaConfiguration. This is a basic setup for using the configuration. ```cpp SugiyamaConfiguration configuration; ``` -------------------------------- ### Implement buildTopBottomPath method Source: https://pub.dev/documentation/graphview/latest/graphview/TreeEdgeRenderer/buildTopBottomPath.html Constructs a path between nodes based on the configuration's connection style. Requires access to node dimensions and positions. ```dart void buildTopBottomPath(Node node, Node child, Offset parentPos, Offset childPos, double parentCenterX, double parentCenterY, double childCenterX, double childCenterY) { final parentBottomY = parentPos.dy + node.height * 0.5; final childTopY = childPos.dy + child.height * 0.5; final midY = (parentBottomY + childTopY) * 0.5; if (configuration.useCurvedConnections) { // Curved connection linePath ..moveTo(childCenterX, childTopY) ..cubicTo( childCenterX, midY, parentCenterX, midY, parentCenterX, parentBottomY, ); } else { // L-shaped connection linePath ..moveTo(parentCenterX, parentBottomY) ..lineTo(parentCenterX, midY) ..lineTo(childCenterX, midY) ..lineTo(childCenterX, childTopY); } } ``` -------------------------------- ### buildSelfLoopPath Method Source: https://pub.dev/documentation/graphview/latest/graphview/EdgeRenderer/buildSelfLoopPath.html Calculates the path and geometry for edges that start and end at the same node. ```APIDOC ## buildSelfLoopPath ### Description Builds a loop path for self-referential edges and returns geometry data that renderers can use to draw arrows or style the segment. ### Parameters #### Arguments - **edge** (Edge) - Required - The edge object to process. Must have identical source and destination nodes. - **loopPadding** (double) - Optional - Padding for the loop radius. Defaults to 16.0. - **arrowLength** (double) - Optional - Length of the arrow segment. Defaults to 12.0. ### Response - **LoopRenderResult?** - Returns a LoopRenderResult object containing the path and arrow positioning, or null if the edge is not a self-loop. ``` -------------------------------- ### Graph Class Constructors Source: https://pub.dev/documentation/graphview/latest/graphview/Graph-class.html Details on how to instantiate the Graph class. ```APIDOC ## Graph() ### Description Initializes a new instance of the Graph class. ### Method Constructor ### Endpoint N/A ### Parameters None ``` -------------------------------- ### Get edgePaint property Source: https://pub.dev/documentation/graphview/latest/graphview/RenderCustomLayoutBox/edgePaint.html Retrieves the current Paint object used for edge rendering. ```dart Paint get edgePaint => _paint; ``` -------------------------------- ### Method: run Source: https://pub.dev/documentation/graphview/latest/graphview/FruchtermanReingoldAlgorithm/run.html Executes the graph layout algorithm, calculating node positions and returning the total graph size. ```APIDOC ## run(Graph? graph, double shiftX, double shiftY) ### Description Executes the layout algorithm on the provided graph. It calculates node positions based on repulsion and attraction forces and applies coordinate shifts. ### Parameters #### Path Parameters - **graph** (Graph?) - Required - The graph object to process. - **shiftX** (double) - Required - Shifts the x-coordinate origin. - **shiftY** (double) - Required - Shifts the y-coordinate origin. ### Response #### Success Response (200) - **Size** (Size) - The calculated size of the graph after layout execution. ``` -------------------------------- ### GET dummyId property Source: https://pub.dev/documentation/graphview/latest/graphview/EiglspergerAlgorithm/dummyId.html Retrieves a unique identifier for a node based on the current node count. ```APIDOC ## GET dummyId ### Description Returns a unique integer identifier for a node, generated using the hash code of a string containing the current node count. ### Method GET ### Endpoint dummyId ### Response - **dummyId** (int) - A unique integer identifier generated from the node count. ``` -------------------------------- ### Initialize GraphViewCustomPainter Source: https://pub.dev/documentation/graphview/latest/graphview/GraphViewCustomPainter/GraphViewCustomPainter.html Use this constructor to create an instance of GraphViewCustomPainter. It requires a graph, an algorithm, and a node widget builder. An optional paint object can also be provided. ```dart GraphViewCustomPainter({ Key? key, required this.graph, required this.algorithm, this.paint, required this.builder, }) : super(key: key); ``` -------------------------------- ### Get Graph Size Source: https://pub.dev/documentation/graphview/latest/graphview/ContainerX/size.html Returns the number of segments in the graph. This is a simple getter for the segments length. ```dart int size() => segments.length; ``` -------------------------------- ### run method Source: https://pub.dev/documentation/graphview/latest/graphview/SugiyamaAlgorithm/run.html Executes the graph layout algorithm and returns the calculated size of the graph. ```APIDOC ## run method ### Description Executes the algorithm to perform graph layout calculations. ### Parameters - **graph** (Graph?) - Required - The graph object to be processed. - **shiftX** (double) - Required - Shifts the x-coordinate origin. - **shiftY** (double) - Required - Shifts the y-coordinate origin. ### Returns - **Size** - The size of the graph after layout calculations. ### Implementation ```dart @override Size run(Graph? graph, double shiftX, double shiftY) { this.graph = copyGraph(graph!); reset(); initSugiyamaData(); cycleRemoval(); layerAssignment(); nodeOrdering(); coordinateAssignment(); shiftCoordinates(shiftX, shiftY); final graphSize = graph.calculateGraphSize(); denormalize(); restoreCycle(); return graphSize; } ``` ``` -------------------------------- ### GraphViewWidget Constructor Source: https://pub.dev/documentation/graphview/latest/graphview/GraphViewWidget/GraphViewWidget.html Details the required and optional parameters for initializing the GraphViewWidget. ```APIDOC ## Constructor: GraphViewWidget ### Description Initializes a new instance of the GraphViewWidget with the necessary delegate, animation controller, and configuration settings. ### Parameters - **key** (Key?) - Optional - The widget key. - **delegate** (GraphChildDelegate) - Required - The delegate responsible for providing graph children. - **paint** (Paint?) - Optional - Custom paint configuration for the graph. - **nodeAnimationController** (AnimationController) - Required - Controller for managing node animations. - **enableAnimation** (bool) - Required - Flag to enable or disable animations. ### Implementation ```dart const GraphViewWidget({ Key? key, required this.delegate, this.paint, required this.nodeAnimationController, required this.enableAnimation, }) : super(key: key); ``` ``` -------------------------------- ### GET /getSpacing Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerAlgorithm/getSpacing.html Calculates the spacing between a left node and a right node within a graph structure. ```APIDOC ## getSpacing method ### Description Calculates the spacing between two nodes in a graph. It determines if the nodes are siblings to apply the appropriate separation configuration and adjusts based on the graph's orientation (vertical or horizontal). ### Parameters - **graph** (Graph) - Required - The graph instance containing the nodes. - **leftNode** (Node?) - Required - The node on the left or top. - **rightNode** (Node) - Required - The node on the right or bottom. ### Implementation ```dart num getSpacing(Graph graph, Node? leftNode, Node rightNode) { var separation = configuration.getSubtreeSeparation(); if (isSibling(graph, leftNode, rightNode)) { separation = configuration.getSiblingSeparation(); } num length = isVertical() ? leftNode!.width : leftNode!.height; return separation + length; } ``` ``` -------------------------------- ### MindmapAlgorithm Constructor Source: https://pub.dev/documentation/graphview/latest/graphview/MindmapAlgorithm/MindmapAlgorithm.html Initializes a new instance of the MindmapAlgorithm class with a specific configuration and optional edge renderer. ```APIDOC ## Constructor: MindmapAlgorithm ### Description Initializes the MindmapAlgorithm with a BuchheimWalkerConfiguration and an optional EdgeRenderer. If no renderer is provided, it defaults to a MindmapEdgeRenderer. ### Parameters - **config** (BuchheimWalkerConfiguration) - Required - The configuration object defining the layout parameters. - **renderer** (EdgeRenderer?) - Optional - The renderer used for drawing edges. Defaults to MindmapEdgeRenderer if null. ### Implementation ```dart MindmapAlgorithm(BuchheimWalkerConfiguration config, EdgeRenderer? renderer) : super(config, renderer ?? MindmapEdgeRenderer(config)); ``` ``` -------------------------------- ### initialNode Property Source: https://pub.dev/documentation/graphview/latest/graphview/GraphView/initialNode.html The initialNode property allows you to set the starting node for the GraphView. It is a getter/setter pair. ```APIDOC ## initialNode Property ### Description Allows setting the initial node to display in the GraphView. ### Type ValueKey? ### Implementation ```dart ValueKey? initialNode; ``` ### Usage This property is part of a getter/setter pair to manage the initial state of the GraphView. ``` -------------------------------- ### CircleLayoutAlgorithm Class Overview Source: https://pub.dev/documentation/graphview/latest/graphview/CircleLayoutAlgorithm-class.html Provides an overview of the CircleLayoutAlgorithm class, its inheritance, constructors, properties, methods, and operators. ```APIDOC ## CircleLayoutAlgorithm Class ### Description Represents an algorithm for arranging graph nodes in a circular layout. ### Inheritance * Object * Algorithm * CircleLayoutAlgorithm ### Constructors #### CircleLayoutAlgorithm(CircleLayoutConfiguration config, EdgeRenderer? renderer) Creates a new CircleLayoutAlgorithm instance. ### Properties * **config** (CircleLayoutConfiguration) - The configuration for the circular layout. (final) * **hashCode** (int) - The hash code for this object. (inherited, no setter) * **nodeOrderedList** (List) - The ordered list of nodes for the layout. (getter/setter pair) * **renderer** (EdgeRenderer?) - The edge renderer to use. (getter/setter pair, override) * **runtimeType** (Type) - A representation of the runtime type of the object. (inherited, no setter) ### Methods #### init(Graph? graph) → void Initializes the algorithm with a graph. (override) #### noSuchMethod(Invocation invocation) → dynamic Invoked when a nonexistent method or property is accessed. (inherited) #### run(Graph? graph, double shiftX, double shiftY) → Size Executes the algorithm to arrange nodes in a circular layout. * @param shiftY Shifts the y-coordinate origin. * @param shiftX Shifts the x-coordinate origin. * @return The size of the graph after layout. (override) #### setDimensions(double width, double height) → void Sets the dimensions for the layout. (override) #### toString() → String Returns a string representation of this object. (inherited) ### Operators #### operator ==(Object other) → bool The equality operator. (inherited) ``` -------------------------------- ### Declare FruchtermanReingoldConfiguration Source: https://pub.dev/documentation/graphview/latest/graphview/FruchtermanReingoldAlgorithm/configuration.html Declare an instance of FruchtermanReingoldConfiguration. This is a common starting point for configuring graph layouts. ```cpp FruchtermanReingoldConfiguration configuration; ``` -------------------------------- ### init method Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerAlgorithm/init.html Initializes the GraphView by processing the provided graph object and positioning its nodes. ```APIDOC ## init method ### Description Initializes the GraphView component. This method takes an optional `Graph` object, performs several internal processing steps including node positioning, and prepares the view. ### Method `init` ### Parameters #### Path Parameters - **graph** (Graph?) - Optional - The graph object to initialize the view with. ### Implementation ```dart @override void init(Graph? graph) { var firstNode = getFirstNode(graph!); // Assumes graph is not null here firstWalk(graph, firstNode, 0, 0); secondWalk(graph, firstNode, 0.0); checkUnconnectedNotes(graph); positionNodes(graph); // shiftCoordinates(graph, shiftX, shiftY); } ``` ### Notes - The implementation assumes that if a `graph` object is provided, it is not null when `getFirstNode` is called. - The `shiftCoordinates` method is commented out and can be optionally enabled. ``` -------------------------------- ### getPreviousNonDummyNode Method Source: https://pub.dev/documentation/graphview/latest/graphview/EiglspergerAlgorithm/getPreviousNonDummyNode.html Retrieves the previous non-dummy node from a list of nodes starting from a given index. ```APIDOC ## getPreviousNonDummyNode ### Description Iterates backwards through a list of nodes starting from the provided index to find the first node that is not marked as a dummy node. ### Parameters - **layerNodes** (List) - Required - The list of nodes in the current layer. - **currentIndex** (int) - Required - The index from which to start searching backwards. ### Returns - **Node?** - The found non-dummy node, or null if no such node exists. ### Implementation ```dart Node? getPreviousNonDummyNode(List layerNodes, int currentIndex) { for (var i = currentIndex - 1; i >= 0; i--) { var previousNode = layerNodes[i]; if (!nodeData[previousNode]!.isDummy) { return previousNode; } } return null; } ``` ``` -------------------------------- ### void initData(Graph? graph) Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerAlgorithm/initData.html Initializes the internal node data structures by iterating through the provided graph's nodes and edges. ```APIDOC ## void initData(Graph? graph) ### Description Initializes the internal state of the graph view by mapping nodes to BuchheimWalkerNodeData and establishing successor/predecessor relationships based on the provided graph edges. ### Parameters #### Path Parameters - **graph** (Graph?) - Optional - The graph object containing nodes and edges to be initialized. ### Implementation ```dart void initData(Graph? graph) { graph?.nodes.forEach((node) { var nodeDatab = BuchheimWalkerNodeData(); nodeDatab.ancestor = node; nodeData[node] = nodeDatab; }); graph?.edges.forEach((element) { nodeData[element.source]?.successorNodes.add(element.destination); nodeData[element.destination]?.predecessorNodes.add(element.source); }); } ``` ``` -------------------------------- ### GET renderObject Source: https://pub.dev/documentation/graphview/latest/graphview/GraphViewElement/renderObject.html Retrieves the underlying RenderObject for the element. Note that this getter will throw an exception if the element has been unmounted. ```APIDOC ## GET renderObject ### Description Returns the underlying RenderObject for this element. If the element has been unmounted, this getter will throw an error. ### Method GET ### Endpoint renderObject ### Implementation ```dart @override RenderCustomLayoutBox get renderObject => super.renderObject as RenderCustomLayoutBox; ``` ``` -------------------------------- ### SharpBendPointShape Class Overview Source: https://pub.dev/documentation/graphview/latest/graphview/SharpBendPointShape-class.html Provides an overview of the SharpBendPointShape class, its inheritance, constructors, properties, methods, and operators. ```APIDOC ## SharpBendPointShape Class ### Description Represents a sharp bend point shape, inheriting from BendPointShape. ### Inheritance * Object * BendPointShape * SharpBendPointShape ### Constructors #### SharpBendPointShape() Creates a new instance of the SharpBendPointShape class. ### Properties #### hashCode → int The hash code for this object. * **Type**: int * **Setter**: no setter (inherited) #### runtimeType → Type A representation of the runtime type of the object. * **Type**: Type * **Setter**: no setter (inherited) ### Methods #### noSuchMethod(Invocation invocation) → dynamic Invoked when a nonexistent method or property is accessed. * **Parameters**: * **invocation** (Invocation) - The invocation details. * **Returns**: dynamic * **Inherited**: yes #### toString() → String A string representation of this object. * **Returns**: String * **Inherited**: yes ### Operators #### operator ==(Object other) → bool The equality operator. * **Parameters**: * **other** (Object) - The object to compare with. * **Returns**: bool * **Inherited**: yes ``` -------------------------------- ### Implement removeCollapsingNodes Method Source: https://pub.dev/documentation/graphview/latest/graphview/GraphViewController/removeCollapsingNodes.html Use this method to reset the collapsedNode variable to null. No specific setup is required. ```csharp void removeCollapsingNodes() { collapsedNode = null; } ``` -------------------------------- ### Initialize EiglspergerAlgorithm Source: https://pub.dev/documentation/graphview/latest/graphview/EiglspergerAlgorithm/EiglspergerAlgorithm.html Constructs an instance of EiglspergerAlgorithm using the provided SugiyamaConfiguration. ```dart EiglspergerAlgorithm(this.configuration) { // renderer = SugiyamaEdgeRenderer(nodeData, edgeData, configuration.bendPointShape, configuration.addTriangleToEdge); } ``` -------------------------------- ### SharpBendPointShape Constructor Source: https://pub.dev/documentation/graphview/latest/graphview/SharpBendPointShape/SharpBendPointShape.html Initializes a new instance of the SharpBendPointShape class. ```APIDOC ## SharpBendPointShape Constructor ### Description Creates a new SharpBendPointShape object. ### Method Constructor ### Endpoint N/A ### Parameters This constructor does not accept any parameters. ### Request Example ```json { "example": "SharpBendPointShape()" } ``` ### Response #### Success Response (200) - **SharpBendPointShape** (object) - A new instance of SharpBendPointShape. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### Initialize Index Property Source: https://pub.dev/documentation/graphview/latest/graphview/ContainerX/index.html Initializes the 'index' property to -1. This is a common starting value for index-based operations. ```csharp int index = -1; ``` -------------------------------- ### BuchheimWalkerConfiguration Constructor Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerConfiguration-class.html Initializes a new configuration instance for the Buchheim-Walker tree layout algorithm. ```APIDOC ## Constructor: BuchheimWalkerConfiguration ### Description Creates a configuration object to define how nodes are spaced and oriented in a tree layout. ### Parameters - **siblingSeparation** (int) - Optional - Distance between siblings. - **levelSeparation** (int) - Optional - Distance between levels. - **subtreeSeparation** (int) - Optional - Distance between subtrees. - **orientation** (int) - Optional - The direction of the tree layout. ``` -------------------------------- ### Get Algorithm Property Source: https://pub.dev/documentation/graphview/latest/graphview/RenderCustomLayoutBox/algorithm.html Access the algorithm property of the GraphView delegate. This is used to retrieve the currently active algorithm. ```dart Algorithm get algorithm => _delegate.algorithm; ``` -------------------------------- ### Get Nodes Implementation Source: https://pub.dev/documentation/graphview/latest/graphview/Graph/nodes.html This getter returns the internal list of nodes. Ensure the list is managed correctly elsewhere. ```dart List get nodes => _nodes; ``` -------------------------------- ### void initData(Graph? graph) Source: https://pub.dev/documentation/graphview/latest/graphview/MindmapAlgorithm/initData.html Initializes the graph data by clearing the internal side map and populating it with new side data for each node in the provided graph. ```APIDOC ## void initData(Graph? graph) ### Description Overrides the base initData method to reset the internal state and initialize side data for all nodes present in the provided graph. ### Parameters #### Parameters - **graph** (Graph?) - Optional - The graph object containing the nodes to be initialized. ### Implementation ```dart @override void initData(Graph? graph) { super.initData(graph); _side.clear(); graph?.nodes.forEach((n) => _side[n] = _SideData()); } ``` ``` -------------------------------- ### init method Source: https://pub.dev/documentation/graphview/latest/graphview/TidierTreeLayoutAlgorithm/init.html The init method is used to initialize the graph structure for the component. ```APIDOC ## init method ### Description Initializes the graph structure for the GraphView component. ### Parameters - **graph** (Graph?) - Optional - The graph object to be initialized. ### Implementation ```dart @override void init(Graph? graph) {} ``` ``` -------------------------------- ### Initialize Double Modifier Source: https://pub.dev/documentation/graphview/latest/graphview/BuchheimWalkerNodeData/modifier.html Initializes a double modifier variable to 0.0. This is a common starting point for numerical modifiers. ```dart double modifier = 0.toDouble(); ``` -------------------------------- ### Implement GraphView Init Method Source: https://pub.dev/documentation/graphview/latest/graphview/BalloonLayoutAlgorithm/init.html This method is called to initialize the GraphView. Implementation can be added if needed. ```dart @override void init(Graph? graph) { // Implementation can be added if needed } ``` -------------------------------- ### Get isSegmentVertex Property Source: https://pub.dev/documentation/graphview/latest/graphview/EiglspergerNodeData/isSegmentVertex.html Use this getter to determine if a vertex is a segment vertex. It returns true if the vertex is a P-vertex or a Q-vertex. ```dart bool get isSegmentVertex => isPVertex || isQVertex; ```