Adding functionality to sum up the subgraph