### Install neo4j-viz with notebook dependencies Source: https://github.com/neo4j/python-graph-visualization/blob/main/docs/antora/modules/ROOT/pages/installation.adoc Install neo4j-viz along with optional dependencies required for running the Jupyter notebook tutorials. ```console pip install neo4j-viz[notebook] ``` -------------------------------- ### Install neo4j-viz with pip Source: https://github.com/neo4j/python-graph-visualization/blob/main/docs/antora/modules/ROOT/pages/installation.adoc Install the latest version of the neo4j-viz library using pip. ```console pip install neo4j-viz ``` -------------------------------- ### Install Required Libraries Source: https://github.com/neo4j/python-graph-visualization/blob/main/examples/gds-example.ipynb Installs the necessary libraries for graph data science and visualization. Ensure these are installed before proceeding. ```python %pip install graphdatascience %pip install matplotlib %pip install python-dotenv ``` -------------------------------- ### Install neo4j-viz with Neo4j support Source: https://github.com/neo4j/python-graph-visualization/blob/main/docs/antora/modules/ROOT/pages/integration/neo4j.adoc Install the neo4j-viz library with the additional Neo4j dependency using pip. ```console pip install neo4j-viz[neo4j] ``` -------------------------------- ### Install Neo4j and Visualization Libraries Source: https://github.com/neo4j/python-graph-visualization/blob/main/examples/neo4j-example.ipynb Installs the necessary Python libraries for Neo4j interaction and visualization. Ensure you have these packages before proceeding. ```python %pip install neo4j %pip install neo4j-viz %pip install python-dotenv ``` -------------------------------- ### Async Generator Function Example Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Illustrates the structure of an asynchronous generator function using TypeScript/JavaScript syntax, including setup for generator execution. ```javascript var o=this&&this.__awaiter||function(c,l,d,s){return new(d||(d=Promise))(function(u,g){function b(p){try{v(s.next(p))}catch(m){g(m)}}function f(p){try{v(s.throw(p))}catch(m){g(m)}}function v(p){var m;p.done?u(p.value):(m=p.value,m instanceof d?m:new d(function(y){y(m)})).then(b,f)}v((s=s.apply(c,l||[])).next())})},n=this&&this.__generator||function(c,l){var d,s,u,g,b={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return g={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function f(v){return function(p){return(function(m){if(d)throw new TypeError("Generator is already executing.");for(;g&&(g=0,m[0]&&(b=0)),b;)try{if(d=1,s&&(u=2&m[0]?s.return:m[0]?s.throw||((u=s.return)&&u.call(s),0):s.next)&&!(u=u.call(s,m[1])).done)return u;switch(s=0,u&&(m=[2&m[0],u.value]),m[0]){case 0:case 1:u=m;break;case ``` -------------------------------- ### Install neo4j-viz and dependencies Source: https://github.com/neo4j/python-graph-visualization/blob/main/examples/nodes_2025_demo.ipynb Installs the neo4j-viz library with GDS and Neo4j support, along with python-dotenv and requests. ```python %pip install "neo4j-viz[gds, neo4j]" python-dotenv requests ``` -------------------------------- ### Install neo4j-viz with GDS support Source: https://github.com/neo4j/python-graph-visualization/blob/main/docs/antora/modules/ROOT/pages/integration/gds.adoc Install the `neo4j-viz` library with the GDS extra dependency. This is required before using the `from_gds` method. ```console pip install neo4j-viz[gds] ``` -------------------------------- ### Install Matplotlib and Palettable Source: https://github.com/neo4j/python-graph-visualization/blob/main/examples/gds-example.ipynb Installs necessary Python packages for custom coloring using matplotlib and palettable libraries. ```python %pip install matplotlib, palettable ``` -------------------------------- ### Install neo4j-viz with Pandas support Source: https://github.com/neo4j/python-graph-visualization/blob/main/docs/antora/modules/ROOT/pages/integration/pandas.adoc Install the neo4j-viz library with the pandas extra dependency to enable DataFrame integration. This command should be run in your console. ```console pip install neo4j-viz[pandas] ``` -------------------------------- ### Handle Resize Start Event Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Initializes the resizing process by capturing original dimensions, setting up event listeners, and calculating initial ratios. It also handles optional callbacks for resize start. ```javascript r.prototype.onResizeStart=function(e,o){if(!(!this.resizable||!this.window)){var n=0,a=0;if(e.nativeEvent&&DQ(e.nativeEvent)?(n=e.nativeEvent.clientX,a=e.nativeEvent.clientY):e.nativeEvent&&K1(e.nativeEvent)&&(n=e.nativeEvent.touches[0].clientX,a=e.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var i=this.props.onResizeStart(e,o,this.resizable);if(i===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var c,l=this.window.getComputedStyle(this.resizable);if(l.flexBasis!=="auto"){var d=this.parentNode;if(d){var s=this.window.getComputedStyle(d).flexDirection;this.flexDir=s.startsWith("row")?"row":"column",c=l.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var u={original:{x:n,y:a,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:Rb(Rb({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||"auto"}),direction:o},g=this.state.flexBasis;this.flexDir==="row"?u.flexBasis=c:this.flexDir==="column"&&(u.flexBasis=c),this.setState(u)}}, ``` -------------------------------- ### Start Animation Sequence Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Initializes the animation process by recording old positions, setting the start time, and enabling updates. ```javascript startAnimation:function(){this.updateOldPositionFromState(),this.startTime=Date.now(),this.t=0,this.currentT=0,this.shouldUpdateAnimator=!0} ``` -------------------------------- ### Install Neo4j Graph Visualization Library Source: https://github.com/neo4j/python-graph-visualization/blob/main/examples/snowflake-example.ipynb Installs the necessary Python library for Snowflake graph visualization. Ensure you have the correct dependencies. ```python %pip install neo4j-viz[snowflake] ``` -------------------------------- ### Sync Python Dependencies and Install Package Source: https://github.com/neo4j/python-graph-visualization/blob/main/CONTRIBUTING.md Installs all required development dependencies and the package in editable mode for Python development. ```sh just py-sync ``` -------------------------------- ### Install neo4j-viz with Snowflake dependency Source: https://github.com/neo4j/python-graph-visualization/blob/main/docs/antora/modules/ROOT/pages/integration/snowflake.adoc Install the neo4j-viz library with the Snowflake extra dependency to enable importing data from Snowflake. ```console pip install neo4j-viz[snowflake] ``` -------------------------------- ### Prototype Inheritance Setup Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Sets up prototype inheritance for functions, ensuring correct constructor and prototype chain. ```javascript yr.prototype=ec.prototype,yr.prototype.constructor=yr,Tn.prototype=vd(ec.prototype),Tn.prototype.constructor=Tn,io.prototype=vd(ec.prototype),io.prototype.constructor=io ``` -------------------------------- ### Start JavaScript Development Server Source: https://github.com/neo4j/python-graph-visualization/blob/main/CONTRIBUTING.md Starts Vite watch builds and Jupyter Lab with hot module reloading for JavaScript development. Changes in `js-applet/src/` will auto-reload in active widget cells. ```sh just js-dev ``` -------------------------------- ### Get Slice from Start Index Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Returns a portion of an array starting from a specified index. Handles negative indices and optional end index. ```javascript function La(T,D,U){var rr=T==null?0:T.length;return rr?(D=U||D===e?1:Gt(D),ge(T,D<0?0:D,rr)):[]} ``` -------------------------------- ### Context Provider/Consumer Setup Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Sets up the basic structure for a context provider and consumer. Used for creating and consuming context in React-like applications. ```javascript var ra={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0} ``` -------------------------------- ### Get Slice with Start and End Indices Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Extracts a portion of an array between specified start and end indices. Handles negative indices and optional arguments. ```javascript function Ke(T,D,U){var rr=T==null?0:T.length;return rr?(U&&typeof U!="number"&&qi(T,D,U)?(D=0,U=rr):(D=D==null?0:Gt(D),U=U===e?rr:Gt(U)),ge(T,D,U)):[]} ``` -------------------------------- ### Setup Node Rendering Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Initializes and configures buffers and shaders for rendering nodes. This method prepares the necessary data structures and WebGL vertex array objects for efficient node visualization. ```javascript setupNodeRendering:function(e){var o=this,n=this.gl,a=new ArrayBuffer(8),i=new Uint32Array(n),c=new Uint8Array(n);this.nodeBuffer===void 0&&(this.nodeBuffer=o.createBuffer()),this.numNodes=e.length;var l=new ArrayBuffer(3*e.length*8),d=new Uint32Array(l),s={};this.activeNodes={};for(var u=0;u0&&arguments[0]!==void 0?arguments[0]:sT;this.viewportBoxBuffer=this.gl.createBuffer(),this.viewportBoxShader.use(),this.viewportBoxShader.setUniform("u_minimapViewportBoxColor",[(e=k5(o))0/255,e1/255,e2/255,e3])} ``` -------------------------------- ### Get Array Slice with Offset Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Returns a slice of an array, starting from a specified offset. Handles default offset and negative values. ```javascript function au(T,D){var U=T==null?0:T.length;return U?(D=D===e?1:Gt(D),ta(T,D)):[]} ``` -------------------------------- ### k-Means and k-Medoids Clustering Setup Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Configures and initializes parameters for k-Means and k-Medoids clustering algorithms. Allows setting the number of clusters, distance metric, and iteration limits. ```javascript function N2(t,r,e,o,n,a){var i;return ei(t)?i=t:i=fk[t]||fk.euclidean,r===0&&ei(t)?i(n,a):i(r,e,o,n,a)}var srr=xl({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),mA=function(r){return srr(r)} ``` -------------------------------- ### Get Slice from End Index Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Returns a portion of an array ending before a specified index. Handles negative indices and optional start index. ```javascript function wv(T,D,U){var rr=T==null?0:T.length;return rr?(D=U||D===e?1:Gt(D),D=rr-D,ge(T,0,D<0?0:D)):[]} ``` -------------------------------- ### Get Slice from End Index (Reverse) Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Returns a portion of an array ending before a specified index, moving towards the beginning. Handles negative indices and optional start. ```javascript function qe(T,D,U){var rr=T==null?0:T.length;return rr?(D=U||D===e?1:Gt(D),D=rr-D,ge(T,D<0?0:D,rr)):[]} ``` -------------------------------- ### Create Example Graph in Neo4j Source: https://github.com/neo4j/python-graph-visualization/blob/main/examples/neo4j-example.ipynb Creates a sample graph with 'Person' and 'Product' nodes and 'BUYS' relationships, including properties, in the Neo4j database. This is useful for testing visualization. ```python from neo4j import GraphDatabase with GraphDatabase.driver(URI, auth=auth) as driver: driver.verify_connectivity() driver.execute_query( """ CREATE (dan:Person {name: 'Dan'}), (annie:Person {name: 'Annie'}), (matt:Person {name: 'Matt'}), (jeff:Person {name: 'Jeff'}), (brie:Person {name: 'Brie'}), (elsa:Person {name: 'Elsa'}), (cookies:Product {name: 'Cookies'}), (tomatoes:Product {name: 'Tomatoes'}), (cucumber:Product {name: 'Cucumber'}), (celery:Product {name: 'Celery'}), (kale:Product {name: 'Kale'}), (milk:Product {name: 'Milk'}), (chocolate:Product {name: 'Chocolate'}), (dan)-[:BUYS {amount: 1.2}]->(cookies), (dan)-[:BUYS {amount: 3.2}]->(milk), (dan)-[:BUYS {amount: 2.2}]->(chocolate), (annie)-[:BUYS {amount: 1.2}]->(cucumber), (annie)-[:BUYS {amount: 3.2}]->(milk), (annie)-[:BUYS {amount: 3.2}]->(tomatoes), (matt)-[:BUYS {amount: 3}]->(tomatoes), (matt)-[:BUYS {amount: 2}]->(kale), (matt)-[:BUYS {amount: 1}]->(cucumber), (jeff)-[:BUYS {amount: 3}]->(cookies), (jeff)-[:BUYS {amount: 2}]->(milk), (brie)-[:BUYS {amount: 1}]->(tomatoes), (brie)-[:BUYS {amount: 2}]->(milk), (brie)-[:BUYS {amount: 2}]->(kale), (brie)-[:BUYS {amount: 3}]->(cucumber), (brie)-[:BUYS {amount: 0.3}]->(celery), (elsa)-[:BUYS {amount: 3}]->(chocolate), (elsa)-[:BUYS {amount: 3}]->(milk) """ ) ``` -------------------------------- ### Initialize Main Entrypoint Function Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html The main function that initializes the visualization library, setting up contexts, renderers, and event handlers. It's the starting point for the visualization's lifecycle. ```javascript knr(e)};function pnr(t){var r=t.cy.container(),e=r&&r.style&&r.style.backgroundColor||"white";return sF(e)} ``` -------------------------------- ### Get Source Endpoint for Edge Rendering Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Retrieves the source endpoint coordinates for an edge, used for rendering. It handles different edge types, including 'haystack' and others, returning the appropriate start point. ```javascript U5.getSourceEndpoint=function(t){var r=t[0]._private.rscratch;switch(this.recalculateRenderedStyle(t),r.edgeType){case"haystack":return{x:r.haystackPts[0],y:r.haystackPts[1]};default:return{x:r.arrowStartX,y:r.arrowStartY}} ``` -------------------------------- ### Initialize Neo4j Viz Instance Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Initializes a new Neo4j Viz instance with specified container and configuration options. Sets up layout and renderer defaults. ```javascript var c5={data:In.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:In.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:In.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:In.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};c5.attr=c5.data;c5.removeAttr=c5.removeData;var l5=function(r){var e=this;r=Nt({},r);var o=r.container;o&&!Sx(o)&&Sx(o[0])&&(o=o[0]);var n=o?o._cyreg:null;n=n||{},n&&n.cy&&(n.cy.destroy(),n={});var a=n.readies=n.readies||[];o&&(o._cyreg=n),n.cy=e;var i=pc!==void 0&&o!==void 0&&!r.headless,c=r;c.layout=Nt({name:i?"grid":"null"},c.layout),c.renderer=Nt({name:i?"canvas":"null"},c.renderer); ``` -------------------------------- ### Setup Relationship Rendering Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Initializes and configures buffers and shaders for rendering relationships. This method prepares data structures and WebGL vertex array objects for visualizing connections between nodes. ```javascript setupRelationshipRendering:function(e){var o=this,n=this.gl,a=new ArrayBuffer(4),i=new Uint32Array(a),c=new Uint8Array(a),l={};this.relBuffer===void 0&&(this.relBuffer=n.createBuffer());for(var d=new ArrayBuffer(e.length*bl*4),s=new Uint32Array(d),u=new Float32Array(d),g=function(f){var v=e[f],p=v.from,m=v.to,y=v.color,k=v.width,x=k===void 0?1:k,_=v.key,S=v.disabled,E=o.idToIndex[p],O=o.idToIndex[m],R=E%Ct,M=Math.floor(E/Ct),I=O%Ct,L=Math.floor(O/Ct),z=[R,M,I,L],j=[I,L,R,M],F=(0,Kn.isNil)(y)?o.defaultRelColor:y,H=xw(S?o.disableRelColor:F);l[_]=f;var q=0,W=function(Z,$,X,Q){s[f*bl+q]=Z,q+=1;for(var lr=0;lr<$.length;lr++)c[lr]=$[lr];s[f*bl+q]=i[0],q+=1,c[0]=X,s[f*bl+q]=i[0],u[f*bl+(q+=1)]=Q,q+=1};W(H,z,255,x),W(H,j,0,x),W(H,z,0,x),W(H,j,0,x),W(H,z,0,x),W(H,j,255,x)},b=0;b{r.pattern??(r.pattern=Abr),qa.init(t,r)}) ``` -------------------------------- ### Create and Render a Basic Graph Source: https://github.com/neo4j/python-graph-visualization/blob/main/docs/antora/modules/ROOT/pages/getting-started.adoc Instantiate Node, Relationship, and VisualizationGraph objects, then render the graph. Use 'size' to control node radius. ```python from neo4j_viz import Node, Relationship, VisualizationGraph nodes = [ Node(id=0, size=10, caption="Person"), Node(id=1, size=10, caption="Product"), Node(id=2, size=20, caption="Product"), Node(id=3, size=10, caption="Person"), Node(id=4, size=10, caption="Product"), ] relationships = [ Relationship( source=0, target=1, caption="BUYS", ), Relationship( source=0, target=2, caption="BUYS", ), Relationship( source=3, target=2, caption="BUYS", ), ] VG = VisualizationGraph(nodes=nodes, relationships=relationships) VG.render(initial_zoom=2) ``` -------------------------------- ### Initialize Snowflake Snowpark Session Source: https://github.com/neo4j/python-graph-visualization/blob/main/examples/snowflake-example.ipynb Sets up a connection to Snowflake using provided account credentials. Configure connection parameters based on your Snowflake setup. ```python import os from snowflake.snowpark import Session # Configure according to your own setup connection_parameters = { "account": os.environ.get("SNOWFLAKE_ACCOUNT"), "user": os.environ.get("SNOWFLAKE_USER"), "password": os.environ.get("SNOWFLAKE_PASSWORD"), "role": os.environ.get("SNOWFLAKE_ROLE"), "warehouse": os.environ.get("SNOWFLAKE_WAREHOUSE"), } session = Session.builder.configs(connection_parameters).create() ``` -------------------------------- ### Dijkstra's Algorithm Entrypoint Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Provides an entry point for Dijkstra's algorithm, designed for finding the shortest paths in a graph. It requires a graph object, a starting node, and a cost function for edges. Note that this implementation does not support negative edge weights. ```javascript var L_,aL; function _G(){ if(aL)return L_; aL=1; var t=eg(),r=xG(); L_=o; var e=t.constant(1); function o(a,i,c,l){ return n(a,String(i),c||e,l||function(d){return a.outEdges(d)}) } function n(a,i,c,l){ var d={},s=new r,u,g=function(f){var v=f.v!==u?f.v:f.w,p=d[v],m=c(f),y=g.distance+m; if(m<0)throw new Error("dijkstra does not allow negative edge weights. " ``` -------------------------------- ### Handle Touch Start Event for Multi-touch Gestures Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Handles the 'touchstart' event to initiate touch interactions, including multi-touch gestures for panning, zooming, and context menu activation. It captures initial touch positions and determines if elements are grabbable or if box selection should be initiated. ```javascript var Q,lr,or,tr,dr,sr,fr,ur,cr,gr,pr,Or,Ir,Mr=function(wr,Ur,Jr,Qr){return Math.sqrt((Jr-wr)*(Jr-wr)+(Qr-Ur)*(Qr-Ur))},Lr=function(wr,Ur,Jr,Qr){return(Jr-wr)*(Jr-wr)+(Qr-Ur)*(Qr-Ur)},Ar;t.registerBinding(t.container,"touchstart",Ar=function(wr){if(t.hasTouchStarted=!0,!!M(wr)){k(),t.touchData.capture=!0,t.data.bgActivePosistion=void 0;var Ur=t.cy,Jr=t.touchData.now,Qr=t.touchData.earlier;if(wr.touches[0]){var oe=t.projectIntoViewport(wr.touches[0].clientX,wr.touches[0].clientY);Jr[0]=oe[0],Jr[1]=oe[1]}if(wr.touches[1]){var oe=t.projectIntoViewport(wr.touches[1].clientX,wr.touches[1].clientY);Jr[2]=oe[0],Jr[3]=oe[1]}if(wr.touches[2]){var oe=t.projectIntoViewport(wr.touches[2].clientX,wr.touches[2].clientY);Jr[4]=oe[0],Jr[5]=oe[1]}var Ne=function(uo){return{originalEvent:wr,type:uo,position:{x:Jr[0],y:Jr[1]}}};if(wr.touches[1]){t.touchData.singleTouchMoved=!0,m(t.dragData.touchDragEles);var se=t.findContainerClientCoords();cr=se[0],gr=se[1],pr=se[2],Or=se[3],Q=wr.touches[0].clientX-cr,lr=wr.touches[0].clientY-gr,or=wr.touches[1].clientX-cr,tr=wr.touches[1].clientY-gr,Ir=0<=Q&&Q<=pr&&0<=or&&or<=pr&&0<=lr&&lr<=Or&&0<=tr&&tr<=Or;var je=Ur.pan(),Re=Ur.zoom();dr=Mr(Q,lr,or,tr),sr=Lr(Q,lr,or,tr),fr=[(Q+or)/2,(lr+tr)/2],ur=[(fr[0]-je.x)/Re,(fr[1]-je.y)/Re];var ze=200,Xe=ze*ze;if(sr=1){for(var mt=t.touchData.startPosition=[null,null,null,null,null,null],dt=0;dt= 0; s--) { var u = s === o - 1 ? [] : this.subGraphs[s + 1].nodes; u.length === 0 ? this.subGraphs[s].nodes.forEach(function(p, m) { var y = p.placement ? p.placement.x : a * (Math.random() - .5), k = p.placement ? p.placement.y : a * (Math.random() - .5); d(p.finestIndex === void 0 ? m : p.finestIndex, y, k, i); }) : u.forEach(function(p) { var m = p.finestIndex, y = i[4 * p.finestIndex], k = i[4 * p.finestIndex + 1], x = Uj({x: y, y: k}, 10, p.planets.length + 1); m += 1; p.planets.forEach(function(_, S) { var E = x[S]; d(m += 1, E.x, E.y, i); var O = Uj({x: E.x, y: E.y}, 10, _.moons.length + 1); _.moons.forEach(function(R, M) { var I = O[M]; d(m += 1, I.x, I.y, i); }); }); }); } } this.physData = []; for (var g = 0; g < 2; g++) { var b = this.newTexture(e, g === 0 ? i : c, Ct), f = this.newFramebuffer(e, b); this.physData.push({texture: b, frameBuffer: f}); } var v = this.enableVerlet ? `precision mediump float; uniform sampler2D u_physData; uniform sampler2D u_connections; uniform sampler2D u_connectionOffsets; uniform sampler2D u_pinnedNodes; uniform sampler2D u_sizeTexture; uniform float u_baseLength; uniform float u_curIteration; uniform float u_iterationMultiplier; uniform vec2 u_gravityCenter; uniform float u_numNodes; uniform float u_gravity; uniform sampler2D u_clusterData; uniform sampler2D u_prevForce; uniform float u_collisionMultiplier; float DAMP = 0.6; float COOL = 0.99998; float TEMP = max(0.02, pow(COOL, u_curIteration)); float TIMESTEP = 1.0 / 30.0; float VELOCITYDECAY = 0.6; float accLimitLow = 500000.0; float accLimitHigh = 750000.0; float accLimitPosHigh = 10000000.0; const float denseNodeThreshold = 1000.0; const float MIN_DISTANCE = 0.00000001; const float MAX_DISTANCE = 1000000000.0; const float MAX_ACCELERATION = 50000.0; vec4 getTextureData(sampler2D texture, float index, float base) { float x = mod(index, base); float y = (index - x) / base; return texture2D(texture, vec2(x + 0.5, y + 0.5) / base); } bool isNan(float val) { return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true; } const float BIG_NUMBER = 999999999999999999.0; bool isInf(float val) { return val > BIG_NUMBER || val < -BIG_NUMBER; } vec2 getDelta(vec2 v1, vec2 v2) { vec2 delta = v1 - v2; float dist = ` : ""; } ``` -------------------------------- ### Zod Check Starts With Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Validates that a string begins with a specified prefix. Creates a regex to enforce the starting pattern. ```javascript thr=ke("$ZodCheckStartsWith",(t,r)=>{ qs.init(t,r); const e=new RegExp(`^${Sk(r.prefix)}.*`); r.pattern??(r.pattern=e), t._zod.onattach.push(o=>{ const n=o._zod.bag; n.patterns??(n.patterns=new Set), n.patterns.add(e) }), t._zod.check=o=>{ o.value.startsWith(r.prefix)||o.issues.push({ origin:"string", code:"invalid_format", format:"starts_with", prefix:r.prefix, input:o.value, inst:t, continue:!r.abort }) } }) ``` -------------------------------- ### Get Rendered Style Property Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Gets the rendered style property of a node or edge, either raw or computed. ```javascript Lb.getRenderedStyle=function(t,r){return r?this.getStylePropertyValue(t,r,!0):this.getRawStyle(t,!0)}; ``` -------------------------------- ### Setup Viewport Rendering Source: https://github.com/neo4j/python-graph-visualization/blob/main/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html Initializes the WebGL buffer and shader for rendering the viewport box. Sets the color for the minimap viewport box. ```javascript var e,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sT;this.viewportBoxBuffer=this.gl.createBuffer(),this.viewportBoxShader.use(),this.viewportBoxShader.setUniform("u_minimapViewportBoxColor",[(e=k5(o))[0]/255,e[1]/255,e[2]/255,e[3]]) ```