MCPcopy Create free account
hub / github.com/srixivas/PcapXray / _normalize_pos

Function _normalize_pos

Source/Module/interactive_gui.py:391–400  ·  view source on GitHub ↗
(pos: dict)

Source from the content-addressed store, hash-verified

389
390
391def _normalize_pos(pos: dict) -> dict:
392 if len(pos) <= 1:
393 return {n: (0.0, 0.0) for n in pos}
394 xs = [p[0] for p in pos.values()]
395 ys = [p[1] for p in pos.values()]
396 cx = (max(xs) + min(xs)) / 2
397 cy = (max(ys) + min(ys)) / 2
398 rng = max(max(xs) - min(xs), max(ys) - min(ys)) or 1.0
399 return {n: ((x - cx) / rng * 1.5, (y - cy) / rng * 1.5)
400 for n, (x, y) in pos.items()}
401
402
403def _mac_label(mac: str) -> str:

Callers 1

_build_graph_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected