Questions tagged [descendant]

Descendant of a vertex v, in the tree data structure, refers to a vertex that is either a child of v or recursively a descendant of any of the children of v.

A tree, in graph theory, is an undirected graph which has a unique path between any pair of vertices. A tree is called rooted, if one particular vertex is assigned as the root.

A rooted tree induces a partial order, where the root is at the highest level, each vertex connected to the root via an edge are called its children. This hierarchy may continue further down, with each vertex having children of its own.

A descendant of any vertex is, therefore, any vertex that can be reached by traversing from parent to child.

132 questions
35
votes
5 answers

Jquery: get ancestors (or descendants) and self

One can use matchedset.find(selector) / matchedset.parents(selector) to get the descendants/ancestors of the current matched set filtered by a selector, but that doesn't include the matched set itself (if it happens to match the selector too). Is…
gsakkis
  • 1,569
  • 1
  • 15
  • 24
24
votes
8 answers

jQuery select descendants, including the parent

Consider the following HTML:
I should be changed red
I should not be changed red.
I should be changed red.
Given a DOM…
Sam
  • 6,167
  • 6
  • 26
  • 24
20
votes
3 answers

XPath query with descendant and descendant text() predicates

I would like to construct an XPath query that will return a "div" or "table" element, so long as it has a descendant containing the text "abc". The one caveat is that it can not have any div or table descendants.
juan234
  • 203
  • 1
  • 2
  • 4
16
votes
4 answers

How can I get/list/see all the descendants of a commit with git (or gitk)?

If you use gitk --all, you can see all the commits of your repo, from all branches. I want something like that except only the descendants of a given commit.
Pistos
  • 23,070
  • 14
  • 64
  • 77
15
votes
3 answers

django-mptt get_descendants for a list of nodes

I am trying to get all descendants(include_self=True) not for one Node, but for a list (a QuerySet) of Nodes. This should be one SQL query. Example (that actually is not working:) some_nodes = Node.objects.filter( ...some_condition... )…
thedk
  • 1,939
  • 1
  • 20
  • 22
14
votes
1 answer

Is it possible to inherit from class with Generic in Python?

Since Python 3.5 you can use Generics and other interesting stuff described in PEP-0484. I tried that and here's a code I have: from typing import TypeVar, Generic, Optional ... _T = TypeVar('T') _S = TypeVar('S') class Pool(Generic[_S, _T]): …
8bitjoey
  • 769
  • 7
  • 17
12
votes
8 answers

O(1) algorithm to determine if node is descendant of another node in a multiway tree?

Imagine the following tree: A / \ B C / \ \ D E F I'm looking for a way to query if for example F is a descendant of A (note: F doesn't need to be a direct descendant of A), which, in this particular case would be true. Only a…
Philip Kamenarsky
  • 2,757
  • 2
  • 24
  • 30
10
votes
3 answers

Find all descendants for points in Python

I need to get all descendants point of links represented with side_a - side_b (in one dataframe) until reach for each side_a their end_point (in other dataframe). So: df1: side_a side_b a b b c c d k l l …
jovicbg
  • 1,523
  • 8
  • 34
  • 74
8
votes
3 answers

MongoDB Tree Model: Get all ancestors, Get all descendants

I have an arbitrary tree structure. Example data structure: root |--node1 | |--node2 | | |--leaf1 | | | |--leaf2 | |--node3 |--leaf3 Each node and leaf has 2 properties: id and name. The important…
Benjamin M
  • 23,599
  • 32
  • 121
  • 201
7
votes
2 answers

Select an element and all its descendant elements

To select an element and all its descendant elements: .media, .media * {color: #f00;} Is there just one selector I can use instead of two selectors separated by a comma? I'm looking for a more efficient way to type this.
chharvey
  • 8,580
  • 9
  • 56
  • 95
6
votes
1 answer

React pass props down to all descendant Components

The use case is I would like to "effortlessly" pass down a certain prop values to all descendant components. Not sure if this is even possible in React. So instead of doing this: class Parent extends Component { constructor() { …
slim1801
  • 531
  • 3
  • 8
  • 19
5
votes
3 answers

Finding all "X-generation" descendants using jQuery

Solved (sort of) Well, I think I solved it (barring edge cases) using the following: function findByDepth(parent, child, depth){ var children = $(); $(child, $(parent)).each(function(){ if($(this).parentsUntil(parent, child).length…
Dan Lugg
  • 20,192
  • 19
  • 110
  • 174
4
votes
2 answers

Descendent or self selector in jQuery

I want to search for all elements with class needle in all elements returned by jQuery('.haystack') and have tried jQuery('.haystack .needle'), but this doesn't seem to pick up the case where an element has both classes. Is there a selector that…
tttppp
  • 7,723
  • 8
  • 32
  • 38
4
votes
5 answers

XSL: How to test if the current node is a descendent of another node

I'm pretty new to XSLT, but need to use it for a CMS using at the moment. I've already come up with a problem, but I'll try to describe my it without going into too much information about the underlying CMS. If you need more context to help me, I…
Ev.
  • 7,109
  • 14
  • 53
  • 87
4
votes
1 answer

How to find types that are direct descendants of a base class?

I need to get all types of an assembly that inherits some base class but only the first descendants. For instance if I have: class Base { } class FirstClass : Base { } class SecondClass : FirstClass { } Now var directOnes =…
nawfal
  • 70,104
  • 56
  • 326
  • 368
1
2 3
8 9