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

bugfix gflow visualization #107

Merged
merged 10 commits into from
Dec 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update docstrings
  • Loading branch information
d1ssk committed Dec 19, 2023
commit b779b0dcb417dd4be891e9ecdfe93827e808346a
23 changes: 17 additions & 6 deletions graphix/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ def __init__(self, G, v_in, v_out, meas_plane=None):
"""
Parameters
----------
G: networkx graph
v_in: list of input nodes
v_out: list of output nodes
meas_plane: dict specifying the measurement planes for each node, except output nodes.
G : :class:`networkx.graph.Graph` object
networkx graph
v_in : list
list of input nodes
v_out : list
list of output nodes
meas_plane : dict
dict specifying the measurement planes for each node, except output nodes.
if None, all measurements are assumed to be in XY-plane.
"""
self.G = G
Expand Down Expand Up @@ -580,7 +584,9 @@ def get_pos_from_gflow(self, g, l_k):

@staticmethod
def edge_intersects_node(start, end, node_pos, buffer=0.2):
"""Determine if an edge intersects a node."""
"""
Determine if an edge intersects a node.
"""
start = np.array(start)
end = np.array(end)
if np.all(start == end):
Expand All @@ -602,7 +608,9 @@ def edge_intersects_node(start, end, node_pos, buffer=0.2):

@staticmethod
def control_point(start, end, node_pos, distance=0.6):
"""Generate a control point to bend the edge around a node."""
"""
Generate a control point to bend the edge around a node.
"""
edge_vector = np.array(end) - np.array(start)
# Rotate the edge vector 90 degrees or -90 degrees according to the node position
cross = np.cross(edge_vector, np.array(node_pos) - np.array(start))
Expand All @@ -616,6 +624,9 @@ def control_point(start, end, node_pos, distance=0.6):

@staticmethod
def bezier_curve(bezier_path, t):
"""
Generate a bezier curve from a list of points.
"""
n = len(bezier_path) - 1 # order of the curve
curve = np.zeros((len(t), 2))
for i, point in enumerate(bezier_path):
Expand Down
Loading