Two Crossing Wires Need Not Share a Net

Download and extract the reader ZIP archive (a compressed collection of files). Links labelled “reader ZIP; extract …” download this archive; after extraction, open the named file. It includes the offline article, full-size Portable Network Graphics (PNG) images, editable Scalable Vector Graphics (SVG) diagrams, complete source code, tests and worksheets.

Two lines cross on a schematic. Do they belong to one electrical net? Geometry alone is insufficient: the connection convention matters. In this lesson you will build a small unpowered drawing, state its rules explicitly, and compare the resulting wire nets before and after three local edits.

An electrical net here means terminals joined by ideal wires. A junction is a declared join. A wire crossing is a geometric intersection that may or may not be a junction. A graph represents relationships as nodes and edges; a connected component is a set of nodes reachable through those edges. That graph term is different from a physical component such as a resistor.

Outcome: predict which named terminals share an ideal wire net, introduce an unintended join, detect a dangling wire end, and restore the baseline. This is a paper and offline-code exercise. It is not a continuity-meter test, a circuit simulator or a powered construction.

Materials and the passive fixture

Use graph paper or the original diagram, a pencil and eraser, the reader files, and Python. No electrical parts or power supply are needed. The drawing names a generic resistor R1 with nominal resistance 1 kΩ, meaning one thousand ohms, solely to show that a finite component connects two wire nets without making them one ideal wire net. J1 names an abstract two-terminal connector. Terminal numbers identify ends; they do not imply a particular vendor footprint.

CSV means comma-separated values, used for the terminal table. The complete Python standard-library analyzer was executed with CPython 3.9.6 (CPython is the reference implementation of Python). That historical host version is recorded for reproducibility, not recommended for deployment. It accepts a small JSON drawing grammar, not an arbitrary SVG image or a KiCad project. CAD means computer-aided design; this checker is not a CAD application. JSON is JavaScript Object Notation; SVG is Scalable Vector Graphics. The drawings and program share the declared geometry, but the program never reads pixels or infers a circuit from artwork.

Unpowered two-net resistor schematic crosses two wires without a junction dot; J1.1 connects to R1.1 and J1.2 to R1.2.
Original constructed transfer/geometry figure. Pan the diagram on a narrow screen, or open the full vector figure — reader ZIP; extract assets/crossing-two-nets.svg.

Declare the connection rules before checking

The official KiCad 9 manual states that crossing wires do not implicitly connect, that an explicit junction joins them, and that a wire endpoint placed on an existing wire connects. We adopt those local conventions in this deliberately smaller grammar. Real KiCad also has label-based connectivity and other features; our checker does not implement them. Text labels in these figures identify terminals, not invisible global net aliases.

  1. Every accepted wire segment is internally connected from end to end.
  2. A shared endpoint, an endpoint landing on another segment, or a named terminal on a wire is an explicit connection site.
  3. An interior-to-interior crossing joins only when its coordinate is explicitly listed in junctions.
  4. A resistor’s two pins stay separate unless wires themselves join them. The resistor is not modeled as a zero-ohm link.
  5. A nearby endpoint is not snapped into place. Integer coordinates must match exactly. A one-unit gap remains a gap.

In the baseline, the crossing is at (180, 60). Both wires continue through that point, and the junction list is empty. The intended terminal groups are therefore {J1.1, R1.1} and {J1.2, R1.2}. R1 belongs between the groups as a component. This checker does not compute its resistance, current, power or voltage.

Predict, run and inject three faults

  1. Open data/constructed/baseline.json. Trace J1.1 to R1.1 and J1.2 to R1.2 on paper. Enter your predictions in data/blank-observations.csv.
  2. Run python3 -m unittest discover -s code -v. Then run python3 code/net_lab.py --input data/constructed/baseline.json --output my-baseline. Read the terminal groups in nets.json and the terminal-to-net CSV. Numeric net names are deterministic output labels, not electrical properties.
  3. Add the explicit junction coordinate (180, 60), or run the supplied dot_fault.json. J1.1 and J1.2 now share an ideal wire net. This bypasses the resistor with a wire-net short in the drawing.
  4. Restore the baseline. Add a branch from (100, 60) to (100, 110) and a named terminal TP1 at the free end, as in t_control.json. The branch endpoint landing on the horizontal wire connects without an interior-X dot. TP means test point.
  5. Remove TP1 while retaining the branch, as in dangling_fault.json. Its free endpoint at (100, 110) is reported as dangling. This is a drawing diagnostic, not proof that an actual board has a disconnected wire.
  6. Move the branch’s starting point from (100, 60) to (100, 61). It no longer touches the horizontal wire. Restore the exact baseline file and verify the original two groups and empty dangling-end list return.
Three local schematic edits compare an explicit crossing junction, a terminal on a T branch and an unconnected branch endpoint.
Original calculated comparison; no measured data. Pan the diagram on a narrow screen, or open the full vector figure — reader ZIP; extract assets/junction-fault-controls.svg.

What the algorithm actually does

Each ideal wire is internally one graph node, and each terminal begins as a separate node. The checker gathers only declared connection sites: wire endpoints, terminal coordinates and explicit junction coordinates. At each such site it joins all wire nodes containing that exact point, together with any terminal nodes there. A union-find structure tracks these joins; it repeatedly merges sets and follows a representative for each set. Bare interior/interior crossings never become connection sites, so their wire nodes remain separate.

Collinear overlaps join through an endpoint lying on both segments. Two co-located terminals with no wire are deliberately left separate: coincidence alone is not a wire declaration in this grammar. This rule is documented and tested, rather than presented as a universal CAD convention. The checker reports endpoints touched by only one segment and no terminal as dangling. It cannot decide whether a dangling end is intentional; you must compare it with the design.

Input is limited to 512 nonzero, axis-aligned wires, 256 terminals, 512 junctions and 256 simple positive resistors. Coordinates are integers bounded by ±1,000,000. Diagonal segments, booleans masquerading as coordinates, malformed collections, duplicate wire IDs, duplicate junctions, unsupported labels and unknown component pins are refused. These restrictions keep the model inspectable. They are not a replacement for a full electrical rules checker, footprint checks or physical inspection.

Evidence and limits

Actual host execution passed 17 tests. Besides the baseline and edits, the suite checks deliberate rail ties, resistor pins staying separate, collinear overlaps, terminals inside wires, malformed input and collection bounds. Translation, a quarter-turn rotation, integer scaling, reordered wire lists and reversed segment endpoints preserve the expected terminal grouping. These controls help distinguish topology from arbitrary coordinate choices.

A passing result establishes only that the supplied declarative model has the reported groups under the declared rules. It cannot show that another schematic file contains the same drawing, that exported artwork retained every junction, that a manufactured board follows it, or that applying power would be safe. No CAD parser, actual component, physical continuity or powered target was tested.

Challenge and worked answer

The baseline resistor provides a physical path between two terminal groups. Why does the analyzer still call them two nets? What changes when you add the crossing dot?

Worked answer

An ideal wire net contracts wire-connected points into one electrical node. A finite resistor is an element between nodes, so its two terminals are not contracted together. Adding the dot joins the two wire paths directly, making R1’s terminals part of the same ideal wire net. The analyzer reports that topological short without needing to calculate a resistance.

Compare Ethernet split pairs with the same continuity map: that exercise asks whether a physical pair structure survives a simple continuity test. Here the question comes earlier—what connections the drawing explicitly declares.

Primary sources and source conditions

Sources were checked on November 30, 2026. Figures, calculations, lesson text and experiment code are original work for this lesson. Linked third-party material is not bundled in the reader.

Complete reproducible code and checks

Both complete files below are also supplied as editable reader files. Commands create new local output directories. PNG means Portable Network Graphics; SVG means Scalable Vector Graphics. These original figure formats preserve the constructed diagrams; the explanatory text remains Hypertext Markup Language (HTML).

net_lab.py — complete file
"""A bounded declarative wire-net checker; not a CAD parser or electrical simulator."""
import argparse,csv,json,re
from pathlib import Path

def point(p):
 if not isinstance(p,(list,tuple)) or len(p)!=2 or any(type(x) is not int or abs(x)>10**6 for x in p):raise ValueError('coordinates must be two bounded integers')
 return tuple(p)

def name(s):
 if not isinstance(s,str) or re.fullmatch(r'[A-Za-z0-9_.-]{1,48}',s) is None:raise ValueError('invalid identifier')
 return s

def on(p,w):
 a,b=w['a'],w['b']
 return min(a[0],b[0])<=p[0]<=max(a[0],b[0]) and min(a[1],b[1])<=p[1]<=max(a[1],b[1])

def validate(d):
 if not isinstance(d,dict) or set(d)!={'wires','terminals','junctions','components'}:raise ValueError('unexpected drawing schema; labels are not supported')
 if not isinstance(d['wires'],list) or len(d['wires'])>512 or not isinstance(d['terminals'],dict) or len(d['terminals'])>256 or not isinstance(d['junctions'],list) or len(d['junctions'])>512 or not isinstance(d['components'],list) or len(d['components'])>256:raise ValueError('wrong collection type or size limit exceeded')
 wires=[];seen=set()
 for w in d['wires']:
  if not isinstance(w,dict) or set(w)!={'id','a','b'}:raise ValueError('bad wire fields')
  ident=name(w['id']);a,b=point(w['a']),point(w['b'])
  if ident in seen or a==b or (a[0]!=b[0] and a[1]!=b[1]):raise ValueError('wire must have a unique id and nonzero axis-aligned segment')
  seen.add(ident);wires.append({'id':ident,'a':a,'b':b})
 terminals={name(k):point(v) for k,v in d['terminals'].items()}
 junctions=[point(p) for p in d['junctions']]
 if len(set(junctions))!=len(junctions):raise ValueError('duplicate junction')
 if any(sum(on(p,w) for w in wires)<2 for p in junctions):raise ValueError('junction must touch at least two wire segments')
 compids=set()
 for c in d['components']:
  if not isinstance(c,dict) or set(c)!={'id','kind','value_ohm','pins'}:raise ValueError('bad component fields')
  ident=name(c['id'])
  if ident in compids or c['kind']!='resistor' or type(c['value_ohm']) not in (int,float) or not 0<c['value_ohm']<=10**12:raise ValueError('this lesson accepts positive finite resistors only')
  if not isinstance(c['pins'],list) or len(c['pins'])!=2 or any(not isinstance(p,str) or p not in terminals for p in c['pins']) or c['pins'][0]==c['pins'][1]:raise ValueError('component pins must be two distinct known terminals')
  compids.add(ident)
 return wires,terminals,junctions

def analyze(d):
 wires,terminals,junctions=validate(d)
 parent={('w',w['id']):('w',w['id']) for w in wires};parent.update({('t',t):('t',t) for t in terminals})
 def find(x):
  while parent[x]!=x:parent[x]=parent[parent[x]];x=parent[x]
  return x
 def union(a,b):
  a,b=find(a),find(b)
  if a!=b:parent[max(a,b)]=min(a,b)
 # Each wire is internally connected. Only these declared connection sites
 # join different wires; a bare interior/interior crossing is absent here.
 sites=set(junctions)|set(terminals.values())|{p for w in wires for p in [w['a'],w['b']]}
 for p in sorted(sites):
  nodes=[('w',w['id']) for w in wires if on(p,w)]
  if nodes:nodes += [('t',t) for t,q in terminals.items() if q==p]
  for node in nodes[1:]:union(nodes[0],node)
 groups={}
 for node in sorted(parent):groups.setdefault(find(node),[]).append(node)
 ordered=sorted(groups.values())
 net={node:'N'+str(i+1) for i,members in enumerate(ordered) for node in members}
 terminal_groups=sorted(sorted(t for kind,t in members if kind=='t') for members in ordered if any(kind=='t' for kind,unused in members))
 dangling=sorted({p for w in wires for p in [w['a'],w['b']] if p not in terminals.values() and sum(on(p,q) for q in wires)==1})
 tn={t:net[('t',t)] for t in sorted(terminals)}
 return {'kind':'constructed drawing topology','physical_test':False,'terminal_groups':terminal_groups,'terminal_net':tn,'wire_net':{w['id']:net[('w',w['id'])] for w in sorted(wires,key=lambda x:x['id'])},'dangling_wire_ends':[list(p) for p in dangling],'a_b_same_wire_net':tn.get('J1.1')==tn.get('J1.2') if 'J1.1'in tn and 'J1.2'in tn else None,'scope':'axis-aligned integer wire segments; no label aliases; components do not union their pins'}

def unique(pairs):
 d={}
 for k,v in pairs:
  if k in d:raise ValueError('duplicate JSON key')
  d[k]=v
 return d

def main():
 p=argparse.ArgumentParser(description=__doc__);p.add_argument('--input',required=True);p.add_argument('--output',required=True);args=p.parse_args()
 try:
  path=Path(args.input)
  if path.stat().st_size>262144:raise ValueError('input larger than 256 KiB')
  drawing=json.loads(path.read_text(),object_pairs_hook=unique);result=analyze(drawing)
 except (ValueError,OSError,RecursionError,UnicodeError) as exc:p.error(str(exc))
 dest=Path(args.output);dest.mkdir(parents=True,exist_ok=True);(dest/'nets.json').write_text(json.dumps(result,indent=2)+'\n')
 with (dest/'terminal-nets.csv').open('w',newline='') as f:
  w=csv.writer(f);w.writerow(['terminal','ideal_wire_net']);w.writerows(result['terminal_net'].items())
 print(json.dumps(result,sort_keys=True))
if __name__=='__main__':main()
test_net_lab.py — complete file
import copy,json,subprocess,sys,tempfile,unittest
from pathlib import Path
import net_lab as n

def base():
 return {'wires':[{'id':'A1','a':[40,60],'b':[300,60]},{'id':'A2','a':[300,60],'b':[300,100]},{'id':'B1','a':[180,20],'b':[180,180]},{'id':'B2','a':[180,180],'b':[300,180]},{'id':'B3','a':[300,180],'b':[300,160]}],'terminals':{'J1.1':[40,60],'J1.2':[180,20],'R1.1':[300,100],'R1.2':[300,160]},'junctions':[],'components':[{'id':'R1','kind':'resistor','value_ohm':1000,'pins':['R1.1','R1.2']}]}
class NetTests(unittest.TestCase):
 def test_no_dot_two_nets(self):
  a=n.analyze(base());self.assertIsInstance(a,dict);self.assertEqual(a['terminal_groups'],[['J1.1','R1.1'],['J1.2','R1.2']]);self.assertFalse(a['a_b_same_wire_net']);self.assertEqual(a['dangling_wire_ends'],[])
 def test_dot_connects_crossing(self):
  d=base();d['junctions']=[[180,60]];self.assertTrue(n.analyze(d)['a_b_same_wire_net'])
 def test_t_endpoint_connects_without_dot(self):
  d=base();d['wires'].append({'id':'T','a':[100,60],'b':[100,110]});d['terminals']['TP1']=[100,110];self.assertIn(['J1.1','R1.1','TP1'],n.analyze(d)['terminal_groups'])
 def test_dangling_and_near_miss(self):
  d=base();d['wires'].append({'id':'T','a':[100,60],'b':[100,110]});self.assertIn([100,110],n.analyze(d)['dangling_wire_ends'])
  d['wires'][-1]['a']=[100,61];a=n.analyze(d);self.assertIn([100,61],a['dangling_wire_ends']);self.assertFalse(a['a_b_same_wire_net'])
 def test_deliberate_tie_and_restoration(self):
  d=base();d['wires'] += [{'id':'C1','a':[40,60],'b':[40,20]},{'id':'C2','a':[40,20],'b':[180,20]}];self.assertTrue(n.analyze(d)['a_b_same_wire_net']);self.assertFalse(n.analyze(base())['a_b_same_wire_net'])
 def test_component_does_not_union_pins(self):self.assertNotEqual(n.analyze(base())['terminal_net']['R1.1'],n.analyze(base())['terminal_net']['R1.2'])
 def test_wire_order_endpoint_direction_invariant(self):
  d=base();d['wires']=[dict(w,a=w['b'],b=w['a']) for w in reversed(d['wires'])];self.assertEqual(n.analyze(d)['terminal_groups'],n.analyze(base())['terminal_groups'])
 def test_translate_rotate_scale_invariant(self):
  for f in [lambda p:[p[0]+17,p[1]-38],lambda p:[-p[1],p[0]],lambda p:[p[0]*3,p[1]*3]]:
   d=base()
   for w in d['wires']:w['a']=f(w['a']);w['b']=f(w['b'])
   d['terminals']={k:f(v) for k,v in d['terminals'].items()};self.assertEqual(n.analyze(d)['terminal_groups'],n.analyze(base())['terminal_groups'])
 def test_collinear_overlap(self):
  d={'wires':[{'id':'a','a':[0,0],'b':[10,0]},{'id':'b','a':[5,0],'b':[15,0]}],'terminals':{'X':[0,0],'Y':[15,0]},'junctions':[],'components':[]};self.assertEqual(n.analyze(d)['terminal_groups'],[['X','Y']])
 def test_terminal_inside_wire(self):
  d=base();d['terminals']['TP']=[80,60];self.assertIn(['J1.1','R1.1','TP'],n.analyze(d)['terminal_groups'])
 def test_colocated_unwired_terminals_stay_separate(self):
  d={'wires':[],'terminals':{'X':[0,0],'Y':[0,0]},'junctions':[],'components':[]};self.assertEqual(n.analyze(d)['terminal_groups'],[['X'],['Y']])
 def test_diagonal_zero_duplicate_wire_refused(self):
  for bad in [{'id':'D','a':[0,0],'b':[1,1]},{'id':'D','a':[0,0],'b':[0,0]},base()['wires'][0]]:
   d=base();d['wires'].append(bad)
   with self.assertRaises(ValueError):n.analyze(d)
 def test_bad_coordinates_and_out_of_bounds(self):
  for p in [[True,0],[.5,0],[float('nan'),0],[10**20,0],[0],None]:
   d=base();d['wires'][0]['a']=p
   with self.assertRaises(ValueError):n.analyze(d)
 def test_bad_junction(self):
  for j in [[[999,999]],[[40,60],[40,60]]]:
   d=base();d['junctions']=j
   with self.assertRaises(ValueError):n.analyze(d)
 def test_unknown_component_pin_and_wrong_schema(self):
  d=base();d['components'][0]['pins'][0]='MISSING'
  with self.assertRaises(ValueError):n.analyze(d)
  with self.assertRaises(ValueError):n.analyze(dict(base(),labels={'VCC':[]}))
 def test_size_limit(self):
  d=base();d['wires']=[{'id':str(i),'a':[i,0],'b':[i,1]} for i in range(513)]
  with self.assertRaises(ValueError):n.analyze(d)
 def test_cli_outputs(self):
  with tempfile.TemporaryDirectory() as td:
   p=Path(td)/'drawing.json';p.write_text(json.dumps(base()));r=subprocess.run([sys.executable,n.__file__,'--input',str(p),'--output',str(Path(td)/'out')],capture_output=True,text=True);self.assertEqual(r.returncode,0,r.stderr);o=json.loads((Path(td)/'out'/'nets.json').read_text());self.assertFalse(o['physical_test']);self.assertFalse(o['a_b_same_wire_net'])
if __name__=='__main__':unittest.main()

Open the offline reader and reproduction instructions — reader ZIP; extract README.txt. The delivered reader ZIP contains this article, preview, original figures, code, tests and blank and constructed data. The blank worksheet is intentionally empty; generated outputs are explicitly constructed.

📡Broadcast the signal — amplify the connection.

Leave a Reply