adjacency-list

How to transform a MSSQL CTE query to MySQL?

本秂侑毒 提交于 2019-12-17 03:40:24
问题 in my MySQL schema, I have the category(id, parentid, name) table In the MSSQL, I have that CTE query (to build a category tree from the bottom up for a supplied category ID: with CTE (id, pid, name) as ( select id, parentid as pid,name from category where id = 197 union all select CTE.pid as id , category.parentid as pid, category.name from CTE inner join category on category.id = CTE.pid ) select * from CTE How to 'transform' that query to MySQL ? 回答1: Unfortunately MySQL doesn't support

Copy in adjacency model

自作多情 提交于 2019-12-13 18:42:43
问题 I need to create a sql stored procedure (Sql Server 2008 - T-SQL) which copies a node in an adjacency model. Table can be seen as having two columns, Id and ParentId (FK to Id). Copying means that also all subordinates need to be copied. I think that using WITH is a good start, but I'm curious if I can do this copy without using Cursors. 回答1: The fundamental problem with adjacency lists is there is no general way in SQL to extract an entire sub tree, so you already have a problem of

Get contagion chain from adjacency matrix, r, igraph

[亡魂溺海] 提交于 2019-12-13 15:51:22
问题 Q.I have a erdos.reyni graph. I infect a vertex and want to see what sequence of vertices the disease would follow? igraph has helful functions like get.adjacency(), neighbors(). Details. This is the adjacency matrix with vertex names instead of 0,1 flags and i'm trying to get the contagion chain out of it. Like the flow/sequence of an epidemic through a graph if a certain vertex is infected. Let's not worry about infection probabilities here (assume all vertices hit are infected with

Read adjacency list of digraph from a text file in C++

眉间皱痕 提交于 2019-12-13 09:53:06
问题 I have a text file which has some number of integers in each line. Example: 1 2 4 3 0 4 2 3 Here 1st line means that the 1st node is connected to nodes numbered 1, 2 and 5. Blank line means 4th node isn't connected to any node. This gives me a directed graph. This SO question might have been helpful but it assumes each line to have 2 integers, whereas in this case it can have any number of integers from 0 to N-1(N is no. of nodes). I just want to know how to read this text file. If I had two

Avoiding Duplicates in Adjacency Linked List Graph

那年仲夏 提交于 2019-12-13 05:52:06
问题 this is my first post here I have looked around and could not find a particular question that is having a problem close enough to mine for me to be able to understand and implement a solution of my own. I found about 3 links that were about a similar project, but not relatively close to the same implementation or problem. I am using a Hashmap that stores keys as strings and values as vertices, with the vertices holding their adjacency lists themselves in order to avoid having to repeatedly do

Will SCC pattern change if we reverse a graph(using Kosaraju's Algorithm)?

孤人 提交于 2019-12-13 02:56:53
问题 Assume we have a digraph, it is not a complete graph and has more than one SCC. I wonder if the patterns of Strongly Connected Component changes if we transpose the graph and use Kosaraju's Algorithm? By saying "transpose the graph" I mean flip the direction of edges. If we try to find SCC in the transposed/reversed graph instead of the original, will the SCC we find be different? I came up with this question as I misunderstood the algorithm of SCC and runs it on my transposed/reversed graph.

How render a Tree in html + php(codeIgniter)

╄→гoц情女王★ 提交于 2019-12-12 23:16:55
问题 I have an adjacency model list and this is the query: SELECT t1.FIO AS lev1, t2.FIO AS lev2, t3.FIO AS lev3, t4.FIO AS lev4, t5.FIO AS lev5, t6.FIO AS lev6, t7.FIO AS lev7, t8.FIO AS lev8, t9.FIO AS lev9, t10.FIO AS lev10, t11.FIO AS lev11, t12.FIO AS lev12, t13.FIO AS lev13, t14.FIO AS lev14, t15.FIO AS lev15, t16.FIO AS lev16, t17.FIO AS lev17, t18.FIO AS lev18, t19.FIO AS lev19, t20.FIO AS lev20, t21.FIO AS lev21, t22.FIO AS lev22, t23.FIO AS lev23, t24.FIO AS lev24 FROM users AS t1 LEFT

checking value in n-depth tree?

允我心安 提交于 2019-12-11 11:40:42
问题 I have two entities, post and category which is a 1:n relationship. I have a reference table with two columns, post_id , category_id The categories table has an id column, a status column and a parent_id column If a category is a child of another category (n-depth) then it's parent_id is not null. If a category is online it's status is 1, otherwise it is 0. What I need to do is find out if a post is visible. This requires: Foreach category joined to the post trace up it's tree to the root

How to create an adjacency list of a directed graph in C?

限于喜欢 提交于 2019-12-11 07:34:22
问题 EDIT: No one has answered yet but I think it has to do with how I'm storing my list. Right now I'm storing every vertex in an array of nodes called G. However I think I need to make it a two dimensional array in order for me not to overwrite data in other Nodes. (This is very confusing) As the title says I'm trying to create a directed graph. I'm running into a problem where each time I try to add a Node to the adjacency list of a vertex it is altering a previous vertex's list. For example I

Boost read_graphml example

ε祈祈猫儿з 提交于 2019-12-11 03:15:07
问题 I'm trying to build a simple GraphML loader using BOOST libraries. I have a GraphML file and I want to load it in a boost adjacency list structure. The graph is directed and the only information that it is stored are the name of the nodes (0,1,2,...) and the edges from one node to another. What I did is: void loadHierarchy(){ // ... std::ifstream inFile; inFile.open("ext.gml", std::ifstream::in); typedef boost::adjacency_list<> Graph; Graph g; boost::read_graphml(inFile, g); // ... } I don't