MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Applying data from a database link to a GraphPlot


You have a list of lists and you want a list of rules.
Check Apply.

dat = {{"PENELOPE", "GUINESS"}, {"NICK", "WAHLBERG"}, {"ED",
   "CHASE"}, {"JENNIFER", "DAVIS"}, {"JOHNNY",
   "LOLLOBRIGIDA"}, {"BETTE", "NICHOLSON"}, {"GRACE",
   "MOSTEL"}, {"MATTHEW", "JOHANSSON"}, {"JOE",
   "SWANK"}, {"CHRISTIAN", "GABLE"}}
Apply[Rule, dat, 2]

Ulrich

Am 13.06.2013 um 08:38 schrieb Paul Pikowsky:

> This is my first project and I am trying to import data from a MySQL query into a GraphPlot expression.
>
> A return from MySQL (Sakila is the example here)
>
> SQLExecute[conn, "SELECT first_name, last_name FROM actor LIMIT 10"]
>
> {{"PENELOPE", "GUINESS"}, {"NICK", "WAHLBERG"}, {"ED",
>  "CHASE"}, {"JENNIFER", "DAVIS"}, {"JOHNNY",
>  "LOLLOBRIGIDA"}, {"BETTE", "NICHOLSON"}, {"GRACE",
>  "MOSTEL"}, {"MATTHEW", "JOHANSSON"}, {"JOE", "SWANK"}, {"CHRISTIAN",
>   "GABLE"}}
>
> (This is not the intended data, just a sample of the output.)
>
> But GraphPlot uses inputs of the form,
>
> GraphPlot[{"d" -> "c", "e" -> "b", "e" -> "c", "e" -> "d", "f" -> "a",
>   "f" -> "b", "f" -> "d", "f" -> "e", "g" -> "a", "g" -> "b",
>  "g" -> "c", "g" -> "e"}, VertexLabeling -> True]
>
> Is there some way in place of converting the output of a data query to the input of a graphplot?  I see that an adjacency matrix is an optional input, but I'd also want to use labels generated from the database.
>




  • Prev by Date: Re: Removing list elements in x by list y
  • Next by Date: Re: Removing list elements in x by list y
  • Previous by thread: Re: Applying data from a database link to a GraphPlot
  • Next by thread: Re: Applying data from a database link to a GraphPlot