# Total weight of a graph

I need to find the total weight of an WeightedAdjacencyGraph. I have a graph in that form

a = WeightedAdjacencyGraph[{...},{...},{...}....etc]


How can I find its total weight?

-

You could just do this: if a graph is undirected:

Total[UpperTriangularize[WeightedAdjacencyMatrix[g]], 2]


if a graph is directed:

Total[WeightedAdjacencyMatrix[g], 2]


or by PropertyValue

Total[PropertyValue[g, EdgeWeight]]

-
Don't forget the self loops! –  Szabolcs Oct 12 '13 at 19:23
@Szabolcs thanks, I missed that. –  halmir Oct 13 '13 at 4:39
totalweight=Total@(PropertyValue[{g, #}, EdgeWeight] & /@ EdgeList[g])