UNPKG

smiles-drawer

Version:

A SMILES drawer and parser. Generate molecular structure depictions in pure JavaScript.

205 lines (158 loc) 30.1 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Hanser.js - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="SmilesDrawer.ArrayHelper.html">ArrayHelper</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.clone">clone</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.contains">contains</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.containsAll">containsAll</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.count">count</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.deepCopy">deepCopy</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.each">each</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.get">get</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.intersection">intersection</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.merge">merge</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.print">print</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.remove">remove</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.removeAll">removeAll</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.removeUnique">removeUnique</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.sortByAtomicNumberDesc">sortByAtomicNumberDesc</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.toggle">toggle</a></li><li data-type='method'><a href="SmilesDrawer.ArrayHelper.html#.unique">unique</a></li></ul></li><li><a href="SmilesDrawer.Atom.html">Atom</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Atom.html#.getDuplicateAtomicNumbers">getDuplicateAtomicNumbers</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#.hasDuplicateAtomicNumbers">hasDuplicateAtomicNumbers</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#.sortByAtomicNumber">sortByAtomicNumber</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#addAnchoredRing">addAnchoredRing</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#addNeighbouringElement">addNeighbouringElement</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#attachPseudoElement">attachPseudoElement</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#backupRings">backupRings</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#canRotate">canRotate</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#getAtomicNumber">getAtomicNumber</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#getAttachedPseudoElements">getAttachedPseudoElements</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#getAttachedPseudoElementsCount">getAttachedPseudoElementsCount</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#getMaxRingbond">getMaxRingbond</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#getOrder">getOrder</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#getRingbondCount">getRingbondCount</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#hasRing">hasRing</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#hasRingbonds">hasRingbonds</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#haveCommonRingbond">haveCommonRingbond</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#isInRing">isInRing</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#maxCommonRingbond">maxCommonRingbond</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#neighbouringElementsEqual">neighbouringElementsEqual</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#restoreRings">restoreRings</a></li><li data-type='method'><a href="SmilesDrawer.Atom.html#setOrder">setOrder</a></li></ul></li><li><a href="SmilesDrawer.CanvasWrapper.html">CanvasWrapper</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#clear">clear</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawAromaticityRing">drawAromaticityRing</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawBall">drawBall</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawCircle">drawCircle</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawDashedWedge">drawDashedWedge</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawDebugPoint">drawDebugPoint</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawDebugText">drawDebugText</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawLine">drawLine</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawText">drawText</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#drawWedge">drawWedge</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#getColor">getColor</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#reset">reset</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#scale">scale</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#setTheme">setTheme</a></li><li data-type='method'><a href="SmilesDrawer.CanvasWrapper.html#updateSize">updateSize</a></li></ul></li><li><a href="SmilesDrawer.Drawer.html">Drawer</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Drawer.html#addRing">addRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#addRingConnection">addRingConnection</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#areConnected">areConnected</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#areVerticesInSameRing">areVerticesInSameRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#backupRingInformation">backupRingInformation</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#chooseSide">chooseSide</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#clearPositions">clearPositions</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#createBridgedRing">createBridgedRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#createNextBond">createNextBond</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#createRing">createRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#draw">draw</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#drawEdges">drawEdges</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#drawVertices">drawVertices</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#edgeRingCount">edgeRingCount</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#extend">extend</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#forceLayout">forceLayout</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getBondCount">getBondCount</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getBridgedRingRings">getBridgedRingRings</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getBridgedRings">getBridgedRings</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getClosestEndpointVertex">getClosestEndpointVertex</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getClosestVertex">getClosestVertex</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getCommonRingbondNeighbour">getCommonRingbondNeighbour</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getCommonRings">getCommonRings</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getCurrentCenterOfMass">getCurrentCenterOfMass</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getCurrentCenterOfMassInNeigbourhood">getCurrentCenterOfMassInNeigbourhood</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getEdgeNormals">getEdgeNormals</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getEdgeWeight">getEdgeWeight</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getFusedRings">getFusedRings</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getHeavyAtomCount">getHeavyAtomCount</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getLargestOrAromaticCommonRing">getLargestOrAromaticCommonRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getNonRingNeighbours">getNonRingNeighbours</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getOverlapScore">getOverlapScore</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getRing">getRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getRingbondType">getRingbondType</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getRingConnections">getRingConnections</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getRingCount">getRingCount</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getSmallestCommonRing">getSmallestCommonRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getSpiros">getSpiros</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getSubringCenter">getSubringCenter</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getSubtreeOverlapScore">getSubtreeOverlapScore</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getTotalOverlapScore">getTotalOverlapScore</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getTreeDepth">getTreeDepth</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#getVerticesAt">getVerticesAt</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#hasBridgedRing">hasBridgedRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#initPseudoElements">initPseudoElements</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#initRings">initRings</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#isEdgeInAromaticRing">isEdgeInAromaticRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#isEdgeInRing">isEdgeInRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#isEdgeRotatable">isEdgeRotatable</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#isPartOfBridgedRing">isPartOfBridgedRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#isPointInRing">isPointInRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#isRingAromatic">isRingAromatic</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#isRingConnection">isRingConnection</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#position">position</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#printRingInfo">printRingInfo</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#removeRing">removeRing</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#removeRingConnection">removeRingConnection</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#removeRingConnectionsBetween">removeRingConnectionsBetween</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#resolvePrimaryOverlaps">resolvePrimaryOverlaps</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#resolveSecondaryOverlaps">resolveSecondaryOverlaps</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#restorePositions">restorePositions</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#restoreRingInformation">restoreRingInformation</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#rotateSubtree">rotateSubtree</a></li><li data-type='method'><a href="SmilesDrawer.Drawer.html#traverseTree">traverseTree</a></li></ul></li><li><a href="SmilesDrawer.Edge.html">Edge</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Edge.html#getBondCount">getBondCount</a></li></ul></li><li><a href="SmilesDrawer.Graph.html">Graph</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Graph.html#._ccCountDfs">_ccCountDfs</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#.getConnectedComponentCount">getConnectedComponentCount</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#_bridgeDfs">_bridgeDfs</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#_init">_init</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#_initInfos">_initInfos</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#addEdge">addEdge</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#addVertex">addVertex</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#clear">clear</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getAdjacencyList">getAdjacencyList</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getAdjacencyMatrix">getAdjacencyMatrix</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getBridges">getBridges</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getComponentsAdjacencyMatrix">getComponentsAdjacencyMatrix</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getEdge">getEdge</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getEdgeList">getEdgeList</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getLargestCycleInSubgraph">getLargestCycleInSubgraph</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getSubgraphAdjacencyList">getSubgraphAdjacencyList</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getSubgraphAdjacencyMatrix">getSubgraphAdjacencyMatrix</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#getVertexList">getVertexList</a></li><li data-type='method'><a href="SmilesDrawer.Graph.html#hasEdge">hasEdge</a></li></ul></li><li><a href="SmilesDrawer.Hanser.html">Hanser</a></li><li><a href="SmilesDrawer.Line.html">Line</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Line.html#clone">clone</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getAngle">getAngle</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getLeftChiral">getLeftChiral</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getLeftElement">getLeftElement</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getLeftVector">getLeftVector</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getLength">getLength</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getNormals">getNormals</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getRightChiral">getRightChiral</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getRightElement">getRightElement</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#getRightVector">getRightVector</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#rotate">rotate</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#rotateToXAxis">rotateToXAxis</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#setLeftVector">setLeftVector</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#setRightVector">setRightVector</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#shorten">shorten</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#shortenFrom">shortenFrom</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#shortenLeft">shortenLeft</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#shortenRight">shortenRight</a></li><li data-type='method'><a href="SmilesDrawer.Line.html#shortenTo">shortenTo</a></li></ul></li><li><a href="SmilesDrawer.MathHelper.html">MathHelper</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.apothem">apothem</a></li><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.centralAngle">centralAngle</a></li><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.innerAngle">innerAngle</a></li><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.meanAngle">meanAngle</a></li><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.polyCircumradius">polyCircumradius</a></li><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.round">round</a></li><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.toDeg">toDeg</a></li><li data-type='method'><a href="SmilesDrawer.MathHelper.html#.toRad">toRad</a></li></ul></li><li><a href="SmilesDrawer.Ring.html">Ring</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Ring.html#.getRing">getRing</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#allowsFlip">allowsFlip</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#clone">clone</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#contains">contains</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#eachMember">eachMember</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#getAngle">getAngle</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#getDoubleBondCount">getDoubleBondCount</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#getOrderedNeighbours">getOrderedNeighbours</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#getPolygon">getPolygon</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#getSize">getSize</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#isBenzeneLike">isBenzeneLike</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#setFlipped">setFlipped</a></li><li data-type='method'><a href="SmilesDrawer.Ring.html#thisOrNeighboursContain">thisOrNeighboursContain</a></li></ul></li><li><a href="SmilesDrawer.RingConnection.html">RingConnection</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.RingConnection.html#.getNeighbours">getNeighbours</a></li><li data-type='method'><a href="SmilesDrawer.RingConnection.html#.getVertices">getVertices</a></li><li data-type='method'><a href="SmilesDrawer.RingConnection.html#.isBridge">isBridge</a></li><li data-type='method'><a href="SmilesDrawer.RingConnection.html#addVertex">addVertex</a></li><li data-type='method'><a href="SmilesDrawer.RingConnection.html#isBridge">isBridge</a></li><li data-type='method'><a href="SmilesDrawer.RingConnection.html#updateOther">updateOther</a></li></ul></li><li><a href="SmilesDrawer.SSSR.html">SSSR</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.SSSR.html#.areSetsEqual">areSetsEqual</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.bondsToAtoms">bondsToAtoms</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.getEdgeCount">getEdgeCount</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.getEdgeList">getEdgeList</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.getPathIncludedDistanceMatrices">getPathIncludedDistanceMatrices</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.getRingCandidates">getRingCandidates</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.getRings">getRings</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.getSSSR">getSSSR</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.isSupersetOf">isSupersetOf</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.matrixToString">matrixToString</a></li><li data-type='method'><a href="SmilesDrawer.SSSR.html#.pathSetsContain">pathSetsContain</a></li></ul></li><li><a href="SmilesDrawer.Vector2.html">Vector2</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Vector2.html#add">add</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#angle">angle</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#clockwise">clockwise</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#clone">clone</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#distance">distance</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#distanceSq">distanceSq</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#divide">divide</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#getRotateAwayFromAngle">getRotateAwayFromAngle</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#getRotateToAngle">getRotateToAngle</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#getRotateTowardsAngle">getRotateTowardsAngle</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#invert">invert</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#isInPolygon">isInPolygon</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#length">length</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#multiply">multiply</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#multiplyScalar">multiplyScalar</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#normalize">normalize</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#normalized">normalized</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#rotate">rotate</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#rotateAround">rotateAround</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#rotateAwayFrom">rotateAwayFrom</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#rotateTo">rotateTo</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#sameSideAs">sameSideAs</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#subtract">subtract</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#toString">toString</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#whichSide">whichSide</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.add">add</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.angle">angle</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.divide">divide</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.dot">dot</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.midpoint">midpoint</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.multiply">multiply</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.multiplyScalar">multiplyScalar</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.normals">normals</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.scalarProjection">scalarProjection</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.subtract">subtract</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.threePointangle">threePointangle</a></li><li data-type='method'><a href="SmilesDrawer.Vector2.html#.units">units</a></li></ul></li><li><a href="SmilesDrawer.Vertex.html">Vertex</a><ul class='methods'><li data-type='method'><a href="SmilesDrawer.Vertex.html#addChild">addChild</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#clone">clone</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#equals">equals</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getAngle">getAngle</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getCommonNeighbours">getCommonNeighbours</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getDrawnNeighbours">getDrawnNeighbours</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getNeighbourCount">getNeighbourCount</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getNeighbours">getNeighbours</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getNextInRing">getNextInRing</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getSpanningTreeNeighbours">getSpanningTreeNeighbours</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#getTextDirection">getTextDirection</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#isNeighbour">isNeighbour</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#isTerminal">isTerminal</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#setParentVertexId">setParentVertexId</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#setPosition">setPosition</a></li><li data-type='method'><a href="SmilesDrawer.Vertex.html#setPositionFromVector">setPositionFromVector</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#SmilesDrawer">SmilesDrawer</a></li></ul> </nav> <div id="main"> <h1 class="page-title">Hanser.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/** A class encapsulating the functionality to find the rings in the graph using Hansers algorithm. */ SmilesDrawer.Hanser = class Hanser { constructor(vertices, edges) { this.vertices = vertices; this.edges = edges; this.cycles = []; this.paths = {}; this.pathIdCounter = 0; this.getRings(); this.removeBridgedRings(); } getRings(vertices, edges) { for (var i = this.edges.length - 1; i >= 0; i--) { this.paths[this.pathIdCounter] = { id: this.pathIdCounter++, nodes: [this.edges[i][0], this.edges[i][1]], source: this.edges[i][0], target: this.edges[i][1], isConnected: false }; this.pathIdCounter++; } for (var i = this.vertices.length - 1; i >= 0; i--) { this.remove(i); } } remove(vertexId) { let paths = this.getPaths(vertexId); for (var i = 0; i &lt; paths.length; i++) { for (var j = i + 1; j &lt; paths.length; j++) { let path = this.splice(paths[i], paths[j]); if (path) { if (path.isConnected) { path.nodes.pop(); this.cycles.push(new Set(path.nodes)); delete this.paths[path.id]; } else { this.paths[path.id] = path; } } } delete this.paths[paths[i].id]; } } getPaths(vertexId) { let paths = []; for (var i in this.paths) { let value = this.paths[i]; if (value.source === vertexId || value.target === vertexId) { paths.push(value); } } return paths; } splice(next, previous) { let intersection = null; let nodes = next.nodes.concat(); if (next.source === previous.source || next.source === previous.target) { intersection = next.source; } else { intersection = next.target; } if (intersection === next.source) { nodes = nodes.reverse(); } if (intersection === previous.source) { for (var i = 1; i &lt; previous.nodes.length; i++) { nodes.push(previous.nodes[i]); } } else { for (var i = previous.nodes.length - 2; i >= 0; i--) { nodes.push(previous.nodes[i]); } } // If the path contains duplicate vertex ids, skip. if (!this.valid(nodes)) { return; } return { id: this.pathIdCounter++, nodes: nodes, source: nodes[0], target: nodes[nodes.length - 1], isConnected: nodes.length > 2 &amp;&amp; nodes[0] === nodes[nodes.length - 1] } } valid(nodes) { for (var i = 1; i &lt; nodes.length; i++) { for (var j = 1; j &lt; nodes.length; j++) { if (i === j) { continue; } if (nodes[i] === nodes[j]) { return false; } } } return true; } removeBridgedRings() { if (this.cycles.length &lt; 2) { return; } let vertexRings = new Array(this.vertices.length); for (var i = 0; i &lt; this.vertices.length; i++) { vertexRings[i] = new Set(); for (var j = 0; j &lt; this.cycles.length; j++) { if (this.cycles[j].has(i)) { vertexRings[i].add(j); } } } // Return if there are no bridged rings (no vertices with ringcount > 2) for (var i = 0; i &lt; vertexRings.length; i++) { if (vertexRings[i].size > 2) { return; } } console.log('vertexRings', vertexRings); } }</code></pre> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sat May 27 2017 22:56:50 GMT+0200 (W. Europe Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>