# Graph Theory Research

InterPSS underlying object model is a directed graph. The goal of this research project is to explore advanced graph theory implementation using InterPSS for power system applications. InterPSS Transmission/Distribution Loss Allocation is an example of using InterPSS graph model to implement a loss allocation algorithm.

### Active Power Flow Path Walk Through

There are situations where one might want walk through an AC Loadflow network, after the convergence of a Loadflow calculation, along the active power flow path in source->load direction or reverse direction (load->source) to perform some analysis. InterPSS has an ActivePowerPathWalkThrough algorithm, which allows you to walk through AC network along the active power flow path, after Loadflow calculation, to do whatever you want. The following code shows how to define an ActivePowerPathWalkThrough algorithm object, Bus and Branch visitor to implement your walking logic:

``NetPathWalkAlgorithm walkAlgo = CoreObjectFactory.createNetPathWalkAlgorithm();``
``walkAlgo.setBusWalker(new AbstractBusPowerFlowPathWalker() {``
``   @Override``
``   public boolean visit(Bus bus) {``
``      bus.setVisited(true);``
``      // do whatever to the bus object along the walk path``
``      return true;``
``   }``
``});``
``walkAlgo.setBranchWalker(new AbstractBranchPowerFlowPathWalker() {``
``   @Override``
``   public boolean visit(Bus bus, Branch branch) {``
``      branch.setVisited(true);``
``      // do whatever to the branch object along the walk path``
``      return true;``
``   }``
``});``

After defining the walk through algorithm object, you can apply the algorithm to an aclfNet object in Source-> Load direction or Load->Source direction, as shown in the following code:

``walkAlgo.setDirection(NetPathWalkDirectionEnum.ALONG_PATH);``
``aclfNet.accept(walkAlgo);``
``walkAlgo.setDirection(NetPathWalkDirectionEnum.OPPOSITE_PATH);``
``aclfNet.accept(walkAlgo);``

A complete sample can be found Here.

Reference