In my head this sounds like a 3D version of this:
Or complete decoupled from the networkx:
import plotly.graph_objects as go
import itertools
# Define vertices
vertices = [
(1, 0, 0), (-1, 0, 0),
(0, 1, 0), (0, -1, 0),
(0, 0, 1), (0, 0, -1)
]
# Function to determine if two vertices form an edge
def is_edge(v1, v2):
diff = sum(abs(a - b) for a, b in zip(v1, v2))
return diff == 2 # octahedron edge condition
# Build edge traces
edge_traces = []
for v1, v2 in itertools.combinations(vertices, 2):
if is_edge(v1, v2):
edge_traces.append(
go.Scatter3d(
x=[v1[0], v2[0]],
y=[v1[1], v2[1]],
z=[v1[2], v2[2]],
mode="lines",
line=dict(color="black", width=4),
hoverinfo="none"
)
)
# Vertex trace
x, y, z = zip(*vertices)
vertex_trace = go.Scatter3d(
x=x,
y=y,
z=z,
mode="markers",
marker=dict(
size=8,
color="red",
symbol="circle"
),
name="Vertices"
)
# Create figure
fig = go.Figure(data=edge_traces + [vertex_trace])
fig.update_layout(
scene=dict(
xaxis=dict(visible=False),
yaxis=dict(visible=False),
zaxis=dict(visible=False),
aspectmode="data"
),
margin=dict(l=0, r=0, t=0, b=0)
)
fig.show()
