Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8933 > unrolled thread

Re: graph

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-03-09 11:09 +0000
Last post2012-03-09 11:09 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: graph Bob Hanlon <hanlonr357@gmail.com> - 2012-03-09 11:09 +0000

#8933 — Re: graph

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-03-09 11:09 +0000
SubjectRe: graph
Message-ID<jjcodt$q7r$1@smc.vnet.net>
data = {
   {1, {11, 6, 13, 22}},
   {2, {35, 10, 12, 8, 28}},
   {3, {23, 31, 19, 14, 11}},
   {4, {9, 15, 7, 13, 33, 19}},
   {5, {28, 8, 32, 34}},
   {6, {27, 13, 1, 11, 20}},
   {7, {13, 4, 15, 17, 21, 32, 8}},
   {8, {7, 32, 5, 28, 2, 12}}};

adjMatrix = With[{m = Max[data]},
   SparseArray[
    Join @@
     (Thread[Thread[{#[[1]], #[[2]]}] -> 1] & /@ data),
    {m, m}]];

adjGraph = AdjacencyGraph[adjMatrix,
  VertexLabels -> "Name", ImageSize -> 600]


Bob Hanlon


On Thu, Mar 8, 2012 at 4:40 AM, clansa <dauphinester@gmail.com> wrote:
> I have this kind of data
> {{1, {11, 6, 13, 22}}, {2, {35, 10, 12, 8, 28}}, {3, {23, 31, 19, 14,
>   11}}, {4, {9, 15, 7, 13, 33, 19}}, {5, {28, 8, 32, 34}}, {6, {27,
>   13, 1, 11, 20}}, {7, {13, 4, 15, 17, 21, 32, 8}}, {8, {7, 32, 5,
>   28, 2, 12}}}
> The node 1 is connected to nodes 11, 6, 13 and 22
> the node 2 is connected to nodes 35,10,12,8 and 28
>
> I want to make a graph gr
> and then to obtain adjency matrix with AdjacencyMatrix[gr]
>
> I work with many nodes (>250
>
> Thanks
> Andrew

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web