Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A time-linear Python implementation of Walker's algorithm for level-based tree layouting/drawing
This package provides a way to generate level-based tree layouts (i.e. (x, y) coordinates for each node in a tree graph, such that nodes with the same depth from the root node are placed on the same y-height) using Walker's algorithm (https://onlinelibrary.wiley.com/doi/abs/10.1002/spe.4380200705) including improvements by Buchheim et al. (2002) to make it linear in time (https://link.springer.com/content/pdf/10.1007/3-540-36151-0_32.pdf). One can then use these layouts to draw the graph in the xy-plane.
You can either directly supply a networkx graph:
from walkerlayout import WalkerLayouting
import networkx as nx
G = nx.Graph()
G.add_nodes_from(range(0,8))
G.add_edges_from([(0,1), (0,2), (0,3), (1,4), (3,5), (3,6), (5,7)])
layout = WalkerLayouting.layout_networkx(graph=G, root_node=0)
nx.draw(G, pos=layout, with_labels=True)
Or define the tree purely in WalkerLayouting
using unique keys:
from walkerlayout import WalkerLayouting
# 0
# /|\
# 1 2 3
# | /\
# 4 5 6
# |
# 7
tree = WalkerLayouting(root_key=0)
tree.add(parent_key=0, child_key=1)
tree.add(parent_key=0, child_key=3)
tree.add(parent_key=0, child_key=2, index=1)
tree.add(parent_key=3, child_key=6)
tree.add_from([(1,4), (3,5,0), (5, 7), (5, 8), (8, 9)]) # (parent, child [,index])
tree.remove(8)
layout = tree.get_layout()
# {
# 0: (0.0, 0.0),
# 1: (-1.0, 1.0),
# 2: (0.0, 1.0),
# 3: (1.0, 1.0),
# 4: (-1.0, 2.0),
# 5: (0.5, 2.0),
# 6: (1.5, 2.0),
# 7: (0.5, 3.0)
# }
Keys can be of any type. However, you can type-hint them to a fixed type:
tree: WalkerLayouting[str] = WalkerLayouting(root_key='root')
Copyright 2023 Elias Foramitti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A time-linear Python implementation of Walker's algorithm for level-based tree layouting/drawing
We found that walkerlayout demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.