- layout-base ^1.0.0
Elements of layout-base can be accessed through this library as well. See below for an example.
avsdf-base as a dependecy to your layout extension.
require() in the extension to reach functionality:
const AVSDFLayout = AVSDFLayout;const AVSDFNode = AVSDFNode;const AVSDFConstants = AVSDFConstants;const PointD = layoutBasePointD;const DimensionD = layoutBaseDimensionD;
The main layout and a Graph Manager (see layout-base for details) connected to this layout is needed with
let avsdfLayout = ;let graphManager = avsdfLayout;let root = graphManager;
Filling in the Graph Manager with nodes and edges are more related to layout-base library than this library. So details have to be found there. But remember to add AVSDF elements as opposed to layout-base elements. Also remember that the root of the Graph Manager should be an AVSDFCircle object.
// Adding a nodeLet node = root;// Adding an edgeLet edge = graphManager;
After all nodes and edges are added. The algorithm can be run as shown below.
// Running the AVSDF layout.avsdfLayout;// Post process is iterated over the sorted list of vertex degrees (descending)let sortedByDegreeList = avsdfLayout;// Post process is done step by step so that it could be displayed more efficientlyfor node in sortedByDegreeListavsdfLayout;// An update for the angles (in radians) for the node angles are neededavsdfLayout;// An update for the node coordinates are neededavsdfLayout;
Note that updateNodeAngles() and updateNodeCoordinates() have to be called at each step if you want to take post processing apart instead of doing it in one go as shown above.