Degrees of separation filter

It seems that when using the ‘Add Existing’, the objects we will most likely want are already linked to people within a couple degrees of separation of the Active Person.

As an example, as I Add a sibling, most of the desired Places/Sources/Citations that already exist will already be Referenced by the people VERY closely related to the person being Added. (A similar function for the People view would have to be based on Home Person instead of Active Person or the view would be in constant update.)

If we could have a Selector filter option that limited to that subset of Objects, selection navigation would be much faster.

There would need to be a fuzziness adjustment to change the degrees of separation.

  • Zero degrees are objects of the Active Person (self). Useful for an obituary source or when a person is born, lived, died & was buried locally.
  • One degree expands to include immediate family (parents, sibs, spouses & offspring).
  • 2 degrees expands to extended family (immediate family of immediate family - including grandparents, grandkids, in-laws, aunts, uncles, nieces & nephews)
  • 3 degrees is probably as far as such a filter would be responsive enough for casual use.

Among the place this kind of feature would most helpful is when merging branches. After you merge the first node, you’d make them the Home Person, going into the Person category view (set to 2 degrees) would let you quickly select & merge the extended family. But more importantly, after each Person merge, you could Flip through the other Categories (with the degrees set to zero/self) and quickly merge those objects.


I’m currently working on filter rules which allow to filter for people based on degrees of seperation.


That’s great!

If it pans out, hopefully there will be a way to get it into some of the selectors too! The hierarchical Place Tree in my database has grown unruly in the last year. So selecting a place has become more of a chore. It’d be nice if Gramps pre-pruned the less likely candidates for me.

(If there’s a family plot or an ancestral home, I keep searching for the same placenames. If I’m filling in a family from an obit or Census, I now rely on Clipboarding a lot. But the clipboard has to be repopulated each session.)

I don’t yet have any experience merging branches, but I think I understand your point about having to repeatedly search for the same Place as you work with records for a set of people like that.

Perhaps another solution that could be helpful would be the ability to select multiple events and assign all of them to the same Place with a single action. This would be done from the Event category view. You could use a custom filter to see events for people within a certain degree of separation of the home person or a bookmarked person, for example, or simply sort the event list by Last Changed date to see the batch that you just entered, or whatever way is useful, and then select all of the ones that you wish to assign to a given place. Then you would click on some new button or link that allows you to set the Place for all of the selected Events, without having to go through the place selection dialog for each one. I have no idea how simple or difficult something that would be to program, or if there are other consequences to consider, but simply from a user productivity perspective it seem it would be useful to be able to select multiple things (in this case, Events) and perform an identical action to each of them (in this case, setting the Place).

Another example of where similar functionality might be useful is when adding people to a census event. Currently I have to create the census event for one person in the household, then go into each other member of the household and add them to the event (unless there’s a faster way that I haven’t discovered yet). It would be nice to simply select all of those other household members from the People category view (again, perhaps using a custom filter for degree of separation), select the ones I want, and then launch some dialog from which I could add all of them at once to the event. And again, I have no idea about the complexity or possible consequences, it just seems like it would be a timesaver.

(I realize there is already the capability to select multiple things and then click on “Edit…” but that just opens multiple dialogs.)

1 Like

Something like this?

1 Like

I, too, have been working on some filters to identify different groups of people such as “first cousins”, “second cousins twice removed (down)”, etc. I would appreciate more discussion on this, since I’m not sure if I’m going about it in the most efficient manner.

What I’ve done so far is to consider each of the possible degrees of separation as fitting into this pattern:

the children (of the children (of the children)) etc., nested from zero to many times

of the siblings (used zero or one time only)

of the parents (of the parents (of the parents)) etc., nested from zero to many times

of a given person (the home person, a bookmarked person, etc.)

That pattern could probably be better expressed in a more formal grammar notation, but here some examples:

If I’m looking for first cousins of a given person, they are the children of the siblings of the parents of the given person. So first I have a filter that returns the siblings of the parents of the given person (that is to say, an “aunts and uncles” filter), then another filter that returns the children of the people who were selected by the first filter.

If I’m looking for the second cousins twice removed (down), they are the children of the children of the children of the children of the siblings of the parents of the parents of the given person. This of course involves more nesting of filters.

The number of times that “parents” occurs indicated the degree of cousin (in the examples above, 1 for first cousin and 2 for second cousin).

The number of times that “parents” occurs, minus number of times that “children” occurs, indicates the degree of removal (in the examples above, 1 - 1 = 0 meaning no removal, and 2 - 4 = -2 meaning twice removed down).

I think the definition works for other relations as well (great-nephews, etc.) by omitting either “children” or “siblings” or “parents” from the chain (which is why I specified their occurrence as zero to many, or zero or one).

I have not yet tested my filters thoroughly, only spot checked the results by using the relationship calculator quick view. And I have not yet considered all of the complexities of half cousins, step cousins, people who are cousins multiple ways, etc. Performance is fine so far but I’m not sure how well it will scale (I currently have about 3,000 people in the database.)

There could be other potential improvements as well, such as limiting the results to maternal or paternal cousins.

Anyway, I would love to hear of other approaches from a user perspective.

1 Like

Yes, exactly, thanks.

I just filed the Feature Request. The thanks will be for the developer that sees a way to do this and then implements it.

I notice that @Mattkmmr has submitted PR #283 which adds a new filter rule.

1 Like

WAY cool! Thanks @Mattkmmr ! … I am looking forward to trying it out!

Yes, thanks @Mattkmmr! I hope it solves a problem that I have in using existing filters such as “siblings of”, which apparently limit to one family, the choice of which seems arbitrary. I have an example where a person has several full siblings in his first family (“first” both in terms of the family ID number and also its order in the Relationship category view), and a half-sibling and step-sibling in his second family. When I used the “siblings of” filter, it returns the half-sibling and step-sibling rather than the full siblings. I will search the bug tracker and see if there is any past discussion about this, and will also think about submitting a change request. I just mention it here as something for you to consider in your new filter.

@emyoulation I fixed the typo, thanks for reporting.

@GeorgeWilmes What you describe happens when a filter searches for the “main parents” of a child who is in more than one family. The “main parents” are the parents of the first family where the child was included. Code

I’ll add options to the filter rules (degrees of seperation and sibling of person, sibling of filter match) to search for all parents (relationship type birth) and all parents (including all relationship types).


I’m working on the reference-level documentation for Matt’s 2 add-on Filter Rules for Degrees of Separation. The new Rule is great!

The Doc page still undergoing continuous revision as I build the supporting sections in the Glossary and the main manual. After the basic reference is done, I’m not sure whether to go after the tutorial or the Template pages that would simplify documenting add-on Rules for new developers.

Don’t expect much yet. It’s preliminary!
Rule Expansions

I still have to delve into Matt’s Degrees of Separation to determine which mathematical approaches of Consanguinity & Affinity he uses. And then to graphically illustrate them.

1 Like

There is no special mathematical approaches of Consanguinity & Affinity in this filter rule. It is mostly a combination of the already existing filter rules IsLessThanNthGenerationAncestorOf and IsLessThanNthGenerationDescendantOf with some additional features.

It works in following steps:

  1. Find root or home person
  2. Get all ancestors of this person less then N generations
  3. For each ancestor/person from step # 2 get all descendants less than N generations

I added an addtional feature for step # 2 to allow to get all parent families of a person if there are more than one. And there is also the possibility to add all partners for all found persons at the end.

The ancestor and descendant calculation use the degree/generation value N a bit differently e.g. for N=3 the will give 2 more ancestor generations calculated (root person = 1, parents = 2, grandparent = 3) but 3 descendant generations down for each person.

I hope that explaination helps! :slightly_smiling_face:



I just have to build an appropriate Tree for experimental testing and run the experiments. The test Tree needs all the edge cases described in the examples of differences of counting degrees by French civil law (Napoleonic code) and canon law (Catholic church). It’s kind of like determining if the the degrees are in Celsius or Fahrenheit and then labeling the recipe’s degrees to avoid burning the cake! (Or whether we’re calculating acceleration due to gravity in Metric vs. ANSI units… so we don’t lose a Mars Climate Orbiter.

Then verify experimentally that the theoretical matching results & actual matching results correspond.

WikiTree has a description of differences (but that’s still a wiki so it will need to find a more authoritative & immutable reference):
Degree of kinship separation is pertinent to legal issues (rights of succession, permission to marry). In French traditions, there are two systems for determining degree of separation:

  1. By canon law (the legal system of the Roman Catholic Church)

  2. By civil law (the Napoleonic code) the


Merged to Addons

1 Like

I have done some testing, and I believe that @emyoulation’s documentation accurately reflects @Mattkmmr’s code. And I understand from @Mattkmmr’s comments that the new rule is based on some existing rules.

However, the results do not seem intuitive. (To keep things simple, I did not test with the options for partners and additional parents.)

0 degrees of separation includes self; but it also returns children (I expect them to be 1 degree separate)

1 degree includes parents and siblings; but also nieces, nephews and grandchildren (I expect them to be 2 degrees separate)


Are my expectations incorrect? I am just counting the number of steps I take in any direction along the tree.

1 Like

I rewrote the filter rule to make it more intuitive. The rule now searches recursivly for the parents, siblings and children of a person, instead of using the rules “ancestors less then N generations” and “descendants less than N generations”.

Degree 0 => main person
Degree 1 => parents, siblings and children of main person
Degree 2 => parents, siblings and children of all persons of degree 1
… and so on.

Pull request #463


Without the Partners included, it creates a biological only Degrees of separation.

Here’s the new pulls’ 1.1.0 version.

How about revising the behavior of the ‘Include Partners’ checkbox?

Currently, the Partners are considered 0 degrees distant. Shouldn’t they add a degree?

Note that would also requiring making 2 degrees include in-laws (including sibling spouses), step-parents & step-children.

Right now it does not check for biological relation between parent-child (adopted, stepchildren, half and full siblings are equal).

I also want to add a “biological only” option to it, but I ran into some problems distinguishing them without making the code too complex or the filter too slow. I need to come up with a better way for that.

That’s the same behaviour as the version had before and also the same behaviour as in other filters. You check first for people related in a certain way or having a certain attribute and then check for all partners of them. I can add an option including in-law relatives and step-children/-parents in future.

1 Like