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

Fix StarConnectivtyPlacer/Router._check_star_connectivity for len(nodes)>5 #1567

Merged
7 changes: 6 additions & 1 deletion src/qibo/transpiler/placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ def __call__(self, circuit: Circuit):

def _check_star_connectivity(self):
"""Check if the connectivity graph is a star graph."""
if len(self.connectivity.node) != 5:
raise_error(
ValueError,
f"This connectivity graph is not a star graph. Length of nodes provided: {self.connectivity.node} != 5.",
)
for node in self.connectivity.nodes:
if self.connectivity.degree(node) == 4:
self.middle_qubit = node
elif self.connectivity.degree(node) != 1:
raise_error(
ValueError,
"This connectivity graph is not a star graph.",
"This connectivity graph is not a star graph. There is a node with degree different from 1 or 4.",
)


Expand Down
7 changes: 6 additions & 1 deletion src/qibo/transpiler/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ def __call__(self, circuit: Circuit):

def _check_star_connectivity(self):
"""Check if the connectivity graph is a star graph."""
if len(self.connectivity.node) != 5:
raise_error(
ValueError,
f"This connectivity graph is not a star graph. Length of nodes provided: {self.connectivity.node} != 5.",
)
for node in self.connectivity.nodes:
if self.connectivity.degree(node) == 4:
self.middle_qubit = node
elif self.connectivity.degree(node) != 1:
raise_error(
ValueError,
"This connectivity graph is not a star graph.",
"This connectivity graph is not a star graph. There is a node with degree different from 1 or 4.",
)


Expand Down