1
$\begingroup$

I have a set of list created from f[vR_] := Map[FindShortestPath[g, vOrigen, #] &, Rest[vR]] which it's looking for the shortest path between a random node(vOrigen) and the rest of the nodes of a graph(g), to create the set i'm using Map[f[#] &, verticesRoom], the lists of the sets aren't linear,for example, the output when vOrigen it's 9 is like this:

{{{9, 1}, {9, 1, 2}, {9, 10, 6}, {9, 10}, **{9}**}, {{9, 1, 2}, {9, 1, 2, 
   3}, {9, 10, 6, 7, 8}, {9, 10, 6, 7}, {9, 10, 6}}, {{9, 1, 2, 
   3}, {9, 1, 2, 3, 4}, {9, 10, 6, 7, 11, 12, 13}, {9, 10, 6, 7, 11, 
   12}, {9, 10, 6, 7, 8}}, {{9, 1, 2, 3, 4}, {9, 1, 2, 3, 4, 5}, {9, 
   10, 14, 15, 16, 17, 18}, {9, 10, 14, 15, 16, 17}, {9, 10, 6, 7, 11,
    12, 13}}, {{9, 10, 6}, {9, 10, 6, 7}, {9, 10, 6, 7, 11}, {9, 10, 
   14, 15}, {9, 10, 14}, {9, 10}}, {{9, 10, 6, 7}, {9, 10, 6, 7, 
   8}, {9, 10, 6, 7, 11, 12}, {9, 10, 6, 7, 11}}, {**{9}**, {9, 10}, {9, 
   10, 14}, {9, 19, 20}, {9, 19}}, {{9, 10, 6, 7, 11}, {9, 10, 6, 7, 
   11, 12}, {9, 10, 6, 7, 11, 12, 13}, {9, 10, 14, 15, 16, 17}, {9, 
   10, 14, 15, 16}, {9, 10, 14, 15}}, {{9, 10, 14}, {9, 10, 14, 
   15}, {9, 10, 14, 15, 16}, {9, 10, 14, 15, 16, 21}, {9, 19, 24, 25, 
   26}, {9, 19, 24, 25}, {9, 19, 20}}, {{9, 10, 14, 15, 16}, {9, 10, 
   14, 15, 16, 17}, {9, 10, 14, 15, 16, 17, 18}, {9, 10, 14, 15, 16, 
   17, 18, 23}, {9, 10, 14, 15, 16, 21, 22}, {9, 10, 14, 15, 16, 
   21}}, {{9, 19}, {9, 19, 20}, {9, 19, 24, 25}, {9, 19, 24}}, {{9, 
   10, 14, 15, 16, 21}, {9, 10, 14, 15, 16, 21, 22}, {9, 10, 14, 15, 
   16, 21, 22, 29}, {9, 19, 24, 27, 28}, {9, 19, 24, 25, 26}}, {{9, 
   10, 14, 15, 16, 21, 22}, {9, 10, 14, 15, 16, 17, 18, 23}, {9, 10, 
   14, 15, 16, 21, 22, 29, 30}, {9, 10, 14, 15, 16, 21, 22, 29}}, {{9,
    19, 24}, {9, 19, 24, 25}, {9, 19, 24, 25, 26}, {9, 19, 24, 27, 
   28}, {9, 19, 24, 27}}}

but when this function create the set of lists of shortest path also compare with vOrigen and i want to delete the element(marked with ** **) of any list identical to vOrigen, since more nodes will be added to vOrigen lately.

$\endgroup$

closed as off-topic by Alexey Popkov, MarcoB, LCarvalho, Itai Seggev, b3m2a1 Aug 16 '17 at 19:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Alexey Popkov, MarcoB, LCarvalho, Itai Seggev, b3m2a1
If this question can be reworded to fit the rules in the help center, please edit the question.

2
$\begingroup$

Say your list about is called list. You can remove all the terms {9} using

list /. {9} -> Nothing

As pointed out by b3m2a1 and Kellen Myers, DeleteCases also works:

DeleteCases[list, {9}, All]
$\endgroup$
  • $\begingroup$ I think it's also worth mentioning DeleteCases with Infinity (or hopefully a more precise level spec) $\endgroup$ – b3m2a1 Aug 4 '17 at 1:22
  • $\begingroup$ I would use level spec All, but I think they have the same effect. Is that what you meant by "more precise"? $\endgroup$ – Kellen Myers Aug 4 '17 at 2:51
  • $\begingroup$ @KellenMyers , No, All is {0,Infinity}, while Infinity is {1,Infinity}. But @b3m2a1 is probably suggesting using {2}, as that is the only level at which you wish to delete {9} $\endgroup$ – Itai Seggev Aug 14 '17 at 21:32
  • $\begingroup$ An interesting distinction. Is it possible that one could delete {9} at level 0 except if list were literally {9}? $\endgroup$ – Kellen Myers Aug 16 '17 at 9:10

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