I'm trying to bring networkx data into cytoscape. I'm using graphml and that part is fine, but I have an attribute parent=node_name that I want to establish a group with. I cannot find out how to map this in cytoscape. Any ideas on how to automatically create groups in cytoscape?
Example:
G = nx.Graph()
G.add_node("server1")
G.add_node("server1_port1", parent="server1")
G.add_node("server1_port2", parent="server1")
G.add_node("server2")
G.add_node("server2_port1", parent="server2)
G.add_node("server2_port2", parent="server2)
G.add_edge("server1_port1", "server2_port1")
nx.write_graphml(G, "output.graphml")
It should look something like this:
+-----------------+
| server1 |
| |
| {port1} {port2} |
| ~ |
| | |
+----|------------+
|
+----|------------+
| server2 |
| | |
| ~ |
| {port1} {port2} |
| |
+-----------------+
Unfortunately, our GraphML reader doesn't support groups -- I can think of ways to do this semi-automatically, but I'm not sure that's what you want. What you would need to do is to add an attribute to each of your nodes (e.g. "parent") and then create the groups using that attribute (the setsApp will help you do that). Once you've created the groups, use the Compound Node visualization to get the look you want.
-- scooter
Related
I want to do a single query that outputs an array of arrays of table rows. Think along the lines of <table><rowgroup><tr><tr><tr><rowgroup><tr><tr>. Is SQL capable of this? (specifically, as implemented in MariaDB, though migration to AWS RDS might occur one day)
The GROUP BY statement alone does not do this, it creates one row per group.
Here's an example of what I'm thinking of…
SELECT * FROM memes;
+------------+----------+
| file_name | file_ext |
+------------+----------+
| kittens | jpeg |
| puppies | gif |
| cats | jpeg |
| doggos | mp4 |
| horses | gif |
| chickens | gif |
| ducks | jpeg |
+------------+----------+
SELECT * FROM memes GROUP BY file_ext WITHOUT COLLAPSING GROUPS;
+------------+----------+
| file_name | file_ext |
+------------+----------+
| kittens | jpeg |
| cats | jpeg |
| ducks | jpeg |
+------------+----------+
| puppies | gif |
| horses | gif |
| chickens | gif |
+------------+----------+
| doggos | mp4 |
+------------+----------+
I've been using MySQL for ~20 years and have not come across this functionality before but maybe I've just been looking in the wrong place ¯\_(ツ)_/¯
I haven't seen an array rendering such as the one you want, but you can simulate it with multiple GROUP BY / GROUP_CONCAT() clauses.
For example:
select concat('[', group_concat(g), ']') as a
from (
select concat('[', group_concat(file_name), ']') as g
from memes
group by file_ext
) x
Result:
a
---------------------------------------------------------
[[puppies,horses,chickens],[kittens,cats,ducks],[doggos]]
See running example at DB Fiddle.
You can tweak the delimiters such as ,, [, and ].
SELECT ... ORDER BY file_ext will come close to your second output.
Using GROUP BY ... WITH ROLLUP would let you do subtotals under each group, which is not what you wanted either, but it would give you extra lines where you want the breaks.
I suspect this question is already well-answered but perhaps due to limited SQL vocabulary I have not managed to find what I need. I have a database with many code:description mappings in a single 'parameter' table. I would like to define a query or procedure to return the descriptions for all (or an arbitrary list of) coded values in a given 'content' table with their descriptions from the parameter table. I don't want to alter the original data, I just want to display friendly results.
Is there a standard way to do this?
Can it be accomplished with SELECT or are other statements required?
Here is a sample query for a single coded field:
SELECT TOP (5)
newid() as id,
B.BRIDGE_STATUS,
P.SHORTDESC
FROM
BRIDGE B
LEFT JOIN PARAMTRS P ON P.TABLE_NAME = 'BRIDGE'
AND P.FIELD_NAME = 'BRIDGE_STATUS'
AND P.PARMVALUE = B.BRIDGE_STATUS
ORDER BY
id
I want to produce 'decoded' results like:
| id | BRIDGE_STATUS |
|--------------------------------------|------------ |
| BABCEC1E-5FE2-46FA-9763-000131F2F688 | Active |
| 758F5201-4742-43C6-8550-000571875265 | Active |
| 5E51634C-4DD9-4B0A-BBF5-00087DF71C8B | Active |
| 0A4EA521-DE70-4D04-93B8-000CD12B7F55 | Inactive |
| 815C6C66-8995-4893-9A1B-000F00F839A4 | Proposed |
Rather than original, coded data like:
| id | BRIDGE_STATUS |
|--------------------------------------|---------------|
| F50214D7-F726-4996-9C0C-00021BD681A4 | 3 |
| 4F173E40-54DC-495E-9B84-000B446F09C3 | 3 |
| F9C216CD-0453-434B-AFA0-000C39EFA0FB | 3 |
| 5D09554E-201D-4208-A786-000C537759A1 | 1 |
| F0BDB9A4-E796-4786-8781-000FC60E200C | 4 |
but for an arbitrary number of columns.
I know dataframes are supposed to be immutable and everything and I know it's not a great idea to try to change them. However, the file I'm receiving has a useless header of 4 columns (the whole file has 50+ columns). So, what I"m trying to do is just get rid of the very top row because it throws everything off.
I've tried a number of different solutions (mostly found on here) like using .filter() and map replacements, but haven't gotten anything to work.
Here's an example of how the data looks:
H | 300 | 23098234 | N
D | 399 | 54598755 | Y | 09983 | 09823 | 02983 | ... | 0987098
D | 654 | 65465465 | Y | 09983 | 09823 | 02983 | ... | 0987098
D | 198 | 02982093 | Y | 09983 | 09823 | 02983 | ... | 0987098
Any ideas?
The cleanest way I've seen so far is something along the lines of filtering out the first row
csv_rows = sc.textFile('path_to_csv')
skipable_first_row = csv_rows.first()
useful_csv_rows = csv_rows.filter(row => row != skipable_first_row)
I have a list of survey results that looks similar to the following:
| Email | Question 1 | Question 2 |
| ----------------- | ---------- | ---------- |
| test#example.com | Always | Sometimes |
| test2#example.com | Always | Always |
| test3#example.com | Sometimes | Never |
Question 1 and Question 2 (and a few others) have the same discrete set of values (from a dropdown list on the survey).
I want to show the data in the following format in Tableau (a table is fine, but a heatmap or highlight table would be best):
| | Always | Sometimes | Never |
| ---------- | ------ | --------- | ----- |
| Question 1 | 2 | 1 | 0 |
| Question 2 | 1 | 1 | 1 |
How can I achieve this? I've tried various combinations of rows and columns and I just can't seem to get close to this layout. Do I need to use a calculated value?
As far as I know - it is not natively possible with Tableau, because what you have is kind of a pivot table.
What you can do is unpivot the whole table as explained here https://stackoverflow.com/a/20543651/5130012, then you can load the data into Tableau and create the table you want.
I did some dummy data and tried it.
That's my "unpivoted" table:
Row,Column,Value
test,q1,always
test,q2,sometimes
test1,q1,sometimes
test1,q2,never
test10,q1,always
test10,q2,always
test11,q1,sometimes
test11,q2,never
And that's how it looks in Tableau:
Good morning,
I'm working on a laravel 5 social-network-like app and I'm trying to use Restfull controllers but I've found a problem
How can I avoid the resource for the user?
I mean, how can I do this:
Route::resource('{username}', 'UserController');
instead of this:
Route::resource('user/{username}´, 'UserController');
The first one takes me to index method inside UserController, but it must take me to show method, taking {username} as the id parameter.
Therefore I would make nested resources like
// user's photos index
Route::resource('{username}/photos´, 'UserPhotosController');
// show one photo (photo_id)
Route::resource('{username}/photos/photo_id´, 'UserPhotosController');
Any ideas?
When defining this: Route::resource('{username}', 'UserController');
These are the routes that get generated by Laravel:
| GET|HEAD | {username} | {username}.index | UserController#index |
| GET|HEAD | {username}/create | {username}.create | UserController#create |
| POST | {username} | {username}.store | UserController#store |
| GET|HEAD | {username}/{{username}} | {username}.show | UserController#show |
| GET|HEAD | {username}/{{username}}/edit | {username}.edit | UserController#edit |
| PUT | {username}/{{username}} | {username}.update | UserController#update |
| PATCH | {username}/{{username}} | | UserController#update |
| DELETE | {username}/{{username}} | {username}.destroy | UserController#destroy |
This table shows that the /{username} route will go to the UserController#index method. Also, If you notice, the show route that gets generated is actually:
{username}/{{username}}
Therefore I wouldn't suggest to use the Resource route generator, instead is best if you defined the routes in an explicit manner. For example:
Route::get('{username}', ['as' => 'username.show', 'uses' => 'UserController#show']);
Also, Laravel reads the routes in the order that they appear. When you define such dynamics routes, make sure that this routes are the last one in your route.php file. Example:
Route::get('about', 'StaticPagesController#about');
Route::get('blog', 'StaticPagesController#blog');
Route::get('contact', 'StaticPagesController#contact');
Route::get('{username}', ['as' => 'username.show', 'uses' => 'UserController#show']);