1
$\begingroup$

I have a list with graphics. Some of elements in the list are None type, how can I display all elements from that list on one picture?

miastaPolozenie={{69, 94}, {16, 77}, {32, 11}, {24, 20}, {34, 53}}
counter=1   
grafiki=Table[None, {i, 1, liczbaMiast*liczbaMiast}]
polaczone={{1, 1, 1, 1, 0}, {1, 1, 1, 1, 0}, {1, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 0, 0, 1, 1}}
For[i = 1, i < liczbaMiast, i++,
    For[j = 1, j < liczbaMiast, j++; counter++,
        If[polaczone[[i, j]] == 1, 
         grafiki[[counter]] = 
         Graphics[Line[{miastaPolozenie[[i]], miastaPolozenie[[j]]}]]]]]

I want to show all elements from 'grafiki'. I hope this is enough, names are not in English, if you need more information, let me know.

$\endgroup$
  • $\begingroup$ Can you give us bit of your code so we know what you are looking at? $\endgroup$ – kickert Jan 17 at 15:01
  • $\begingroup$ Please edit the question and make sure it's self-contained (don't post code in comments). See here for guidelines: mathematica.meta.stackexchange.com/q/2126/12 $\endgroup$ – Szabolcs Jan 17 at 15:05
  • $\begingroup$ Sorry, deleted comment and edited the post. $\endgroup$ – Janusz Jan 17 at 15:11
  • $\begingroup$ This example is neither minimal, nor complete. Please show a complete minimal example. You may also be interested in reading about better alternatives to For, Nothing and DeleteCases (as a last resort to remove any Nones). $\endgroup$ – Szabolcs Jan 17 at 15:18
  • $\begingroup$ But maybe you just want SimpleGraph[AdjacencyGraph[polaczone], VertexCoordinates -> miastaPolozenie] $\endgroup$ – Szabolcs Jan 17 at 15:23
3
$\begingroup$

It appears that you are trying to visualize a graph based on an adjacency matrix.

The simplest way to merely visualize it is

GraphPlot[polaczone, VertexCoordinates -> miastaPolozenie, VertexSize -> 0.2]

If you want to manipulate the graph, build a Graph.

AdjacencyGraph[polaczone, VertexCoordinates -> miastaPolozenie]

You can remove self-loops with SimpleGraph.

| improve this answer | |
$\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.