       Re: Integers networks

• To: mathgroup at smc.vnet.net
• Subject: [mg82318] Re: [mg82246] Integers networks
• From: Fred Meinberg <fredm at wolfram.com>
• Date: Wed, 17 Oct 2007 04:10:29 -0400 (EDT)

```Hi Felice,

The syntax is little compact, I agree.

The main function is FactorInteger, which returns the prime factors
of a number together with its exponents.

The [[All,1]] part returns only the first elements of the lists, that
is, the prime factors, not the exponents.

Thread[Rule[#,...]] makes sure that for each list of factor integers,
a list of rules is returned. For instance, 6 will go into {6->2, 6->3}.

Array is a function like Table but with a more compact syntax. So
Array[f, 2] gives {f, f}, the same output as Table[f[i], {i,1,2}].

The Array expression returns a list of lists of rules. But for the
graph we want a flat list of rules connecting the nodes. So we use
the Flatten command.

I hope this helps.

-Fred-

On Oct 16, 2007, at 9:41 AM, <frusso at micron.com> wrote:

> Fred thanks
> It works. Please can you exaplin me better the following command?
> It is
> a function that for each number give the prime factor. But I didin't
> understand how it works.
>
> Flatten@Array[Thread[Rule[#, FactorInteger[#][[All, 1]]]] &, i]
>
> Thanks.  Felice
>
>
> -----Original Message-----
> From: Fred Meinberg [mailto:fredm at wolfram.com]
> Sent: Tuesday, October 16, 2007 10:18 AM
> To: frusso
> Cc: mathgroup at smc.vnet.net
> Subject: Re: [mg82246] Integers networks
>
> try
>
> graph[i_] := Flatten@Array[Thread[Rule[#, FactorInteger[#][[All, 1]]]]
> &, i]
>
> a nice visualization is:
>
> Manipulate[GraphPlot[graph[i], SelfLoopStyle -> None], {i, 1, 100, 1}]
>
> On Oct 16, 2007, at 3:26 AM, Felice Russo wrote:
>
>> Hi
>> This is my first post in this forum.
>> I would like to generate a graph where each node is an integer number
>> and the edges the prime factors. For example the node 10 and
>> 2 will have an edge as also the nodes 10 and 5 being 2 and 5 the
>> prime
>
>> factors of 10.
>> And so on....
>> I know that I can generate the graph by using the adjacent matrix but
>> I think that there should be a more smart and easy method. Can you
>> help me?
>>
>> Thanks.  Felice

```

• Prev by Date: Re: Integrate question
• Next by Date: RE: Integers networks
• Previous by thread: Re: Integers networks
• Next by thread: RE: Integers networks