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


Groups > comp.soft-sys.math.mathematica > #14863

Re: Applying data from a database link to a GraphPlot

From Tomas Garza <tgarza10@msn.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Applying data from a database link to a GraphPlot
Date 2013-06-14 08:45 +0000
Message-ID <kpel7d$hqb$1@smc.vnet.net> (permalink)
References <20130613063835.7C7166A65@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


The example you provide is not a very interesting one, since each of the
pairs is disconnected from the rest. To illustrate the point, though, I
 modified some of the pairs and added some others to obtain the list:
labs = {{"PENELOPE", "GUINESS"}, {"JOE", "GUINESS"}, {"JOHNNY",
   "WAHLBERG"}, {"ED", "CHASE"}, {"JENNIFER", "DAVIS"}, {"JOHNNY",
   "LOLLOBRIGIDA"}, {"BETTE", "NICHOLSON"}, {"LOLLOBRIGIDA",
   "MOSTEL"}, {"MATTHEW", "JOHANSSON"}, {"JOE", "JOHNNY"}, {"CHRISTIAN",
   "GABLE"}, {"BETTE", "WAHLBERG"}, {"JOE", "JOHANSSON"}, {"GABLE",
   "JOHANSSON"}, {"GUINNESS", "WAHLBERG"}, {"ED", "JOE"}, {"JENNIFER",
   "MATTHEW"}}


Then you obtain the graph plot with labeled vertices:

GraphPlot[Table[Rule[labs[[j, 1]], labs[[j, 2]]], {j, 1, Length[labs]}],

 VertexLabeling -> True]


-Tomas


> From: ppksky@gmail.com
> Subject: Applying data from a database link to a GraphPlot
> To: mathgroup@smc.vnet.net
> Date: Thu, 13 Jun 2013 02:38:35 -0400
>
> 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.
>

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Applying data from a database link to a GraphPlot Tomas Garza <tgarza10@msn.com> - 2013-06-14 08:45 +0000
  Re: Applying data from a database link to a GraphPlot Paul Pikowsky <ppksky@gmail.com> - 2013-06-16 09:13 +0000

csiph-web