  In this Letter, I introduce an algorithmic method to find the conservative
energy and non-conservative power of a large class of electric circuits,
including superconducting loops, based on the incidence matrix of the circuits'
digraph. I consider only two-port linear (except for simple nonlinear elements)
circuits with holonomic constraints provided by either Kirchhoff's current laws
or Kirchhoff's voltage laws. The method does not require to find any
Lagrangian. Instead, the circuit's classical or quantum Hamiltonian is obtained
from the energy of the reactive (i.e., conservative) circuit elements by means
of transformations complementary to Hamilton's equations. Dissipation and
fluctuations are accounted for by using the Rayleigh dissipation function and
defining generalized Poisson brackets. Non-conservative elements (e.g., noisy
resistors) are included ab initio using the incidence-matrix method, without
needing to treat them as separate elements. Finally, I show that in order to
form a complete set of canonical coordinates, auxiliary (i.e., parasitic)
circuit elements are required to find the Hamiltonian of circuits with an
incomplete set of generalized velocities. In particular, I introduce two
methods to eliminate the coordinates associated with the auxiliary elements by
either Hamiltonian or equation-of-motion reduction.
