Skip to content

Commit

Permalink
Clarifies code a bit, changes convert_neo4j_types > convert_types_to_…
Browse files Browse the repository at this point in the history
…string
  • Loading branch information
marimeireles committed Apr 21, 2021
1 parent fb8b3c1 commit 219432d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ipycytoscape/cytoscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def add_graph_from_neo4j(self, g):
"""
import neotime

def convert_neo4j_types(node_attributes):
def convert_types_to_string(node_attributes):
"""
Converts types not compatible with cytoscape to strings.
Expand Down Expand Up @@ -643,6 +643,10 @@ def get_node_labels_by_priority(g):
"""
counts = dict()

# This counts the number of instances that a node has a particular
# label (a node can have multiple labels in Neo4j).
# counts.get(label, 0) initializes the count with zero, and then
# increments the value if more of the same labels are encountered.
for node in g.nodes:
for label in node.labels:
counts[label] = counts.get(label, 0) + 1
Expand Down Expand Up @@ -671,7 +675,7 @@ def create_tooltip(node_attributes, node_labels):
node_attributes = dict(node)

# convert Neo4j specific types to string
node_attributes = convert_neo4j_types(node_attributes)
node_attributes = convert_types_to_string(node_attributes)

# create tooltip text string
if not "tooltip" in node_attributes:
Expand Down Expand Up @@ -704,7 +708,7 @@ def create_tooltip(node_attributes, node_labels):
rel_attributes = dict(rel)

# convert Neo4j specific types to string
rel_attributes = convert_neo4j_types(rel_attributes)
rel_attributes = convert_types_to_string(rel_attributes)

# assign name of the relationship
if not "name" in rel_attributes:
Expand Down

0 comments on commit 219432d

Please sign in to comment.