hierarchical

Designing interface for hierarchical entity

戏子无情 提交于 2019-12-19 06:24:10
问题 I have to design an interface for hierarchical entity: interface HierarchicalEntity<T extends HierarchicalEntity<T>> { T getParent(); Stream<T> getAncestors(); } It's quite easy to implement default getAncestors() method in terms of getParent() in such a way that the former would return Stream of all the ancestors. Implementation example: default Stream<T> getAncestors() { Stream.Builder<T> parentsBuilder = Stream.builder(); T parent = getParent(); while (parent != null) { parentsBuilder.add

Selecting columns from pandas MultiIndex

本秂侑毒 提交于 2019-12-17 10:34:24
问题 I have DataFrame with MultiIndex columns that looks like this: # sample data col = pd.MultiIndex.from_arrays([['one', 'one', 'one', 'two', 'two', 'two'], ['a', 'b', 'c', 'a', 'b', 'c']]) data = pd.DataFrame(np.random.randn(4, 6), columns=col) data What is the proper, simple way of selecting only specific columns (e.g. ['a', 'c'] , not a range) from the second level? Currently I am doing it like this: import itertools tuples = [i for i in itertools.product(['one', 'two'], ['a', 'c'])] new

Recursive function inside class with foreach changes public value where it shouldn't

北战南征 提交于 2019-12-14 04:20:52
问题 Ok, I'm really stucked with this. I hope you can help me. I have my class, used to manage hierarchical data. The input is a plain array with the following structure (just an example): $list = array( (object) array('id' => 1, 'nombre' => 'Cámaras de fotos', 'parentId' => null), (object) array('id' => 2, 'nombre' => 'Lentes', 'parentId' => null), (object) array('id' => 3, 'nombre' => 'Zoom', 'parentId' => 2), (object) array('id' => 4, 'nombre' => 'SLR', 'parentId' => 1), (object) array('id' =>

C# MVVM TreeView TwoWay-Binding of hierarchical data

落花浮王杯 提交于 2019-12-13 03:35:27
问题 I googled for an answer to this for more than two weeks now. This usually means either I am blind or the idea is absurd. Anyways: In a middle-sized, quite flexible project I'm storing configuration data in a hierarchical structure in the like of this one: Configuration (collection) Audio (class) BaseDir (struct) PlayMode (enum) Input (class) CalibrateOnConnect (bool) KnownDevices (collection) ... (class) ... UseDevice (integer) Playlist (collection) FirstAudio (class) Path (string) Repeat

How To Get All children and itself from Hierarchical data with CTE In SQL Server 2005 using stored procedure

半城伤御伤魂 提交于 2019-12-12 09:11:13
问题 I have many similar structure tables like this: CREATE TABLE [dbo].[tbl_Hierarchy]( [ID] [int] NOT NULL, [ParentID] [int] NOT NULL, [Text] [nvarchar](100) NOT NULL, --other field irrelevant to my question ) INSERT INTO dbo.tbl_Hierarchy VALUES(1,0,'parent1') INSERT INTO dbo.tbl_Hierarchy VALUES(2,0,'parent2') INSERT INTO tbl_Hierarchy VALUES(3,1,'child1') INSERT INTO tbl_Hierarchy VALUES(4,3,'grandchild1') INSERT INTO tbl_Hierarchy VALUES(5,2,'child2') Can you help me writing such as a stored

Multilevel Hierarchical Edge Bundling

拥有回忆 提交于 2019-12-12 01:47:00
问题 I want to implement multilevel hierarchical edge bundling. By that I means I want to inculcate the behavior of radial tree like hierarchy and edge bundling like in Hierarchical Edge Bundling. The sample visualization is Radial Hierarchical bundling I know I need to use two d3.js layout for that. Also I need to change my json dataset accordingly. My sample dataset is only for normal d3.js HEB [ {"name": "A", "imports": ["A1", "A2", "A3"]}, {"name": "B", "imports": ["B1", "B2", "B3"]}, {"name":

Oracle, Connect By rownum

自作多情 提交于 2019-12-11 13:50:43
问题 I tried to find some informations about connect by "engine". I found this post: Confusion with Oracle CONNECT BY User krokodilko answered and says: The analyze of the last query: select level from dual connect by rownum<10; I leave to you as a homework assignment. So i tried to do exactly as described to query Select rownum from dual connect by rownum < 3 And here's my "work": CREATE TABLE step1 AS SELECT 1 "LEVEL" FROM dual; SELECT * FROM step1; create table step2 as SELECT 2 "LEVEL" from

drawing hierarchical tree with orthogonal lines ( HV-Drawing – Binary Tree)

泄露秘密 提交于 2019-12-11 07:52:58
问题 I need to work on drawing a hierarchical tree structure (HV-Drawing – Binary Tree) with orthogonal lines(straight rectangular connecting lines) between root and children ( like the following: http://lab.kapit.fr/display/visualizationlayouts/Hierarchical+Tree+layout ). I want to know if there are any open source examples of the algorithm of drawing trees like that so that I can implement the same algorithm in actionscript. Thanks Palash 回答1: I did a C# version and put the code up on

php convert array into a hierarchical nested set for database

送分小仙女□ 提交于 2019-12-11 05:48:27
问题 So I read this: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ And i'm using mysql and php What I need is script that convert only for one time the old data into data with the left/right values. I don't need to add/update things. The php data $in_array = array ( array( 'id' => 400, 'n' => 'Sub 1a', 's' => array ( array ( 'n' => 'Sub 1b', 'id' => 421, 's' => array ( array ( 'n' => 'Sub 1c', 'id' => 422, ) ) ) ) ), array( 'id' => 500, 'n' => 'Sub 2a', 's' => array ( array

Pandas hierarchical sort

亡梦爱人 提交于 2019-12-11 04:17:40
问题 I have a dataframe of categories and amounts. Categories can be nested into sub categories an infinite levels using a colon separated string. I wish to sort it by descending amount. But in hierarchical type fashion like shown. How I need it sorted CATEGORY AMOUNT Transport 5000 Transport : Car 4900 Transport : Train 100 Household 1100 Household : Utilities 600 Household : Utilities : Water 400 Household : Utilities : Electric 200 Household : Cleaning 100 Household : Cleaning : Bathroom 75