Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert elements to dictionary of lists #10

Open
JohannesWiesner opened this issue Apr 11, 2022 · 0 comments
Open

Convert elements to dictionary of lists #10

JohannesWiesner opened this issue Apr 11, 2022 · 0 comments

Comments

@JohannesWiesner
Copy link
Owner

In the documentation it says that elements can also be provided as a dictionary of lists (Alternatively, a dictionary with the format { 'nodes':[], 'edges':[]} is allowed at initialization, but arrays remain the recommended format)":

elements (list|dict; optional): A list of dictionaries representing the elements of the networks. 1. Each dictionary describes an element, and specifies its purpose. -group(string): Either 'nodes' or 'edges'. If not given, it's automatically inferred. -data(dictionary): Element specific data. -id(string): Reference to the element, useful for selectors and edges. Randomly assigned if not given. -label(string): Optional name for the element, useful whendata(label)is given to a style'scontentorlabel. It is only a convention. -parent(string): Only for nodes. Optional reference to another node. Needed to create compound nodes. -source(string): Only for edges. The id of the source node, which is where the edge starts. -target(string): Only for edges. The id of the target node, where the edge ends. -position(dictionary): Only for nodes. The position of the node. -x(number): The x-coordinate of the node. -y(number): The y-coordinate of the node. -selected(boolean): If the element is selected upon initialisation. -selectable(boolean): If the element can be selected. -locked(boolean): Only for nodes. If the position is immutable. -grabbable(boolean): Only for nodes. If the node can be grabbed and moved by the user. -classes(string): Space separated string of class names of the element. Those classes can be selected by a style selector. 2. Theofficial Cytoscape.js documentation offers an extensive overview and examples of element declaration. Alternatively, a dictionary with the format { 'nodes':[], 'edges':[]} is allowed at initialization, but arrays remain the recommended format.

Besides, each dictionary can also have an attribute "nodes" or "edges". Either way, this would be make the content of elements much more explicit. Right now functions get_edge_dicts and get_node_dicts are implemented to 'find' which elements in elements are edges and which are nodes. Using the approach from above would make these functions obsolete + the app would probably run faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant