Tag Info

New answers tagged

2

Is it acceptable for your problem to change the costs associated to traversing the edges? If it is, then you can set the costs to: costs = { 1, 1, 1, 1, 10, 10, 10, 1, 10, 10, 10, 1, 1, 10, 10, 10, 1, 10, 10, 10, 1, 1, 1, 1 }; (* The following is your original code: *) g = Graph[{0 -> 11, 0 -> 12, 0 -> 13, 11 -> 21, 11 -> ...


1

Doing this is pretty straightforward; you'll want to take a look at the documentation for Mathematica's string patterns primarily. As an example, to use DictionaryLookup with the "ar" and "h" instance you mention, the following are basically equivalent: matches1 = DictionaryLookup[s__ /; !StringContainsQ[s, "ar"|"h"]]; matches2 = ...


4

Something like this words = DictionaryLookup[s__ /; StringFreeQ[s, "ar" | "h"]]; Length[words] 70781 sorted = SortBy[words, StringLength]; Short[sorted] {"a", "I", "AC", "ad", "AD", <<70772>>, "Andrianampoinimerina", "buckminsterfullerene", "institutionalization", "internationalization"}


1

The idea is to just to find one path at a time and remove those vertices from the graph and find the next one, by restring the flow. Not sure if this is still a minimum cost flow in the end. Also using source and targets for assignment, usually you need to set the cost of from the sources and targets to 0. It seems the FindMiniumCost only solves the ...



Top 50 recent answers are included