Group Abstract Group Abstract

Message Boards Message Boards

How to remove zero weight paths from graph for Markov Process ?

Posted 10 years ago

Hello!

I have a software model represented by weighted, directed graph. From the model, I extract a WeightedAdjacencyMatrix for a DiscreteMarkovProcess simulation. Recently, we set some of the edge weights to zero to indicate that we would like to exclude those edges from the simulation.

It turns out that DiscreteMarkovProcess just does not like zero vectors... :) I'm trying to figure out a clean way to remove the "blocked paths" from the model.

I've tried several approaches - but each is pretty ugly. I expect that I'm not the first one to run into this problem... so I'm seeking advice from my learned colleagues :) - any input would be appreciated!

-chris

POSTED BY: Chris Ruhl
Posted 10 years ago

This problem has been resolved, but I'm not sure how to close the question ... The solution as it turns out was not as complex as I had expected:

    EdgeCount[theModel]
    VertexCount[theModel]
    ConnectedGraphQ[theModel]

    1507
    1052
    True

    edgeCleanG = Fold[EdgeDelete[#1, #2[[1]]]&,theModel,
        Select[Transpose[{EdgeList[theModel], 
          PropertyValue[theModel, EdgeWeight]}], #[[2]] == 0&]];

    vertCleanG = VertexDelete[edgeCleanG, 
       Map[#[[1]]&, Drop[ConnectedComponents[edgeCleanG], 1]]];

       EdgeCount[vertCleanG]
    VertexCount[vertCleanG]
    ConnectedGraphQ[vertCleanG]
    1109
    782
    True
POSTED BY: Chris Ruhl
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard