4
$\begingroup$

Is it possible to make (Weighted)AdjacencyMatrix from a graph whose elements have custom properties?

Consider this graph:

g = Graph[{
      Property[DirectedEdge[0, 1], {"WaterFlow" -> x, "PipeWidth" -> 10.0}],
      Property[DirectedEdge[1, 2], {"WaterFlow" -> x + y, "PipeWidth" -> 8.5}],
      Property[DirectedEdge[2, 1], {"WaterFlow" -> y, "PipeWidth" -> 8.5}],
      Property[DirectedEdge[2, 3], {"WaterFlow" -> x, "PipeWidth" -> 10.0}]
    }]

enter image description here

How do I make one WeightedAdjacencyMatrix weighted by "WaterFlow" and another one weighted by "PipeWidth"?

For example, the one for "WaterFlow" would be:

enter image description here

$\endgroup$
3
$\begingroup$

You could specify custom properties to set edge weights using undocumented option EdgeWeight:

WeightedAdjacencyMatrix[g, EdgeWeight -> "WaterFlow"] // MatrixForm

enter image description here

WeightedAdjacencyMatrix[g, EdgeWeight -> "PipeWidth"] // MatrixForm

enter image description here

Since this option is not documented, its behavior could be changed later though.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.