# Associations, who is telling the truth?

**URL:** <https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662>\
**Category:** Help\
**Created:** [June 26, 2026, 10:10am UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662 "2026-06-26T10:10:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PLegoux](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/plegoux/32/413_2.png) [@PLegoux](https://gramps.discourse.group/u/PLegoux)\
**Post date:** [June 26, 2026, 10:10am UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/1 "2026-06-26T10:10:26Z")

</div>

(Gramps v6.0.8 @linux)

Between the Check Associations Data tool and the Deep Connexion gramplet who tell the truth?

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/a/a654cae335b41dcd0f88dbc84059f3a10d5fda97.png)

The “Check Associations Data” tool states that Jumel Guillaume is Ysel Michel’s uncle[oncle] (which is the case), whereas Deep Connexion Gramplet claims he is his nephew[neveu]!

A bug somewhere in the Deep Connexion gramplet?

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [June 26, 2026, 10:59am UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/2 "2026-06-26T10:59:15Z")

</div>

I have asked this question before in a different way with no answer.

Is the Association a “To” or “From” relationship?

i.e., if the Association for John Smith “Godparent” is added to Mark Jones, then which person is the godchild and which person is the godchild?

When the relationship is symetrical (e.g., “cousins”) then they are the same and it doesn’t matter. Nor does it matter as far as running the [Sync Associations addon tool](https://www.gramps-project.org/wiki/index.php/Addon:SyncAssociation). (It merely adds the reciprocal Association between the current person and the associated person to the Associated Person [iff](https://en.wikipedia.org/wiki/If_and_only_if) it does not already exist.)

The dialog needs some feedback.  
Perhaps (like the Name Display editor in preferences) the dialog could preview a formatted description of the Association as it might appear in a biography?

So, adding an Association to Fred Thompson starts with:

> Fred Thompson has an undefined Association with an unknown person.

Then, as a Person and Association type are added, the Preview updates.

[Another different example](https://gramps.discourse.group/t/four-questions-ideas-associations-tags-hotkeys-copynpaste-support-maybe-it-is-possible-to-fix/3096/4) suggests:

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/b/b0626a90a6921756fea956812a760db56b071454.png)

There is a bug report and Deep Connections and Associations:

- [0012024](https://gramps-project.org/bugs/view.php?id=12024): [Deep Connections] Notes and Associations take precedence over direct biological connections.

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 11:37am UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/3 "2026-06-26T11:37:01Z")

</div>

> [@emyoulation](#):
>
> the Association a “To” or “From” relationship?

I guess it is inherited from the ASSO tag (and definition) from the gedcom file format. As there is not a clear direction on the documentation, gramps model only provides a pseudo-free form.

[https://homepages.rootsweb.com/~pmcbride/gedcom/55gcch2.htm#ASSOCIATION\_STRUCTURE](https://homepages.rootsweb.com/~pmcbride/gedcom/55gcch2.htm#ASSOCIATION_STRUCTURE)

> **[ASSOCIATION\_STRUCTURE - The FamilySearch GEDCOM Specification](https://gedcom.io/specifications/FamilySearchGEDCOMv7.html#ASSOCIATION_STRUCTURE)**
>
> A specific building, plot, or location. The payload is the full formatted address as it would appear on a mailing label, including appropriate line breaks (encoded using CONT tags). The expected order of address components varies by region; the...

The check associations tool only reads our data as deep connections makes calculation. Both are right!!! To fill uncle (oncle) or nephew (neveu) is just a starting point issue… a bi-directional associations or design issue, which could be missing on gedcom definition?

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 11:51am UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/4 "2026-06-26T11:51:44Z")

</div>

> [@romjerome](#):
>
> deep connections makes calculation.

According to screenshot, it does not only make calculation… I just wonder where this value is set around (association)!

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [June 26, 2026, 12:42pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/5 "2026-06-26T12:42:06Z")

</div>

Thanks @romjerome

Unfortunately, that hotlink preview on Discourse mangled the content a bit:

Here’s that [linked section from RootsWeb](https://gedcom.io/specifications/FamilySearchGEDCOMv7.html#ASSOCIATION_STRUCTURE):

> **ASSOCIATION\_STRUCTURE:** =
> 
> ` n ASSO @<XREF:INDI>@ {0:M}`  
> ` +1 RELA <RELATION_IS_DESCRIPTOR>` \> `{1:1}`  
> ` +1 <<NOTE_STRUCTURE>> {0:M}`  
> ` +1 <<SOURCE_CITATION>> {0:M}`
> 
> [NOTE: The ASSOCIATION\_STRUCTURE can only link to an INDIVIDUAL\_RECORD.]

Directionality is clarified in the RELATION\_IS\_DESCRIPTOR linked section:

> `RELATION_IS_DESCRIPTOR: = {Size=1:25}`  
> A word or phrase that states object 1’s relation is object 2. For example you would read the following as “Joe Jacob’s great grandson is the ~~submitter pointed to by the @`<XREF:SUBM>`@”:~~ person pointed to by the @`<XREF:INDI>`@":
> 
> ` 0 INDI`  
> ` 1 NAME Joe /Jacob/`  
> ` 1 ASSO @<XREF:SUBM>@`  
> ` 1 ASSO @<XREF:INDI>@`  
> ` 2 RELA great grandson`
> 
> [NOTE: The ASSOCIATION\_STRUCTURE can only link to an INDIVIDUAL\_RECORD.]

There is a relationship chunk in the vCard 4 `.vcf` specification. The Import plug-in could be enhanced to support that Association. (And have special parsing to build Families other of the Immediate Family pre-defined association terms. (And maybe any pre-defined Associations in Gramps.)

The cited [gedcom.io section for GEDCOM7](https://gedcom.io/specifications/FamilySearchGEDCOMv7.html#ASSOCIATION_STRUCTURE) has more exposition. (The use of the `@VOID@` `ASSO` pointer to a Person who does not exist in the tree is intriguing.)

> [@Do Importers plugins allow fallbacks?](https://gramps.discourse.group/t/do-importers-plugins-allow-fallbacks/3652/9):
>
> #### Family & Personal Relationships
> 
> - **`child`** – Offspring
> - **`parent`** – Mother, father, or legal guardian
> - **`sibling`** – Brother or sister
> - **`spouse`** – Husband, wife, or legal partner
> - **`kin`** – General relative or family member
> - **`sweetheart`** / **`crush`** / **`date`** – Romantic interests

---

<div class="post-metadata">

**Author:** ![comeng](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@comeng](https://gramps.discourse.group/u/comeng)\
**Post date:** [June 26, 2026, 1:06pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/6 "2026-06-26T13:06:30Z")

</div>

Once again putting my stupid head on, for me a true Association by definition should never come with up with a Familial relationship unless they are on purely for the purposes of creating a DNA Segment map. For me they are mutually exclusive and the familial link should be used unless there is no other alternative.

phil

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [June 26, 2026, 1:20pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/7 "2026-06-26T13:20:11Z")

</div>

> [@comeng](#):
>
> for me a true Association by definition should never come with up with a Familial relationship unless they are on purely for the purposes of creating a DNA Segment map.

That subsection with familial associations is from `.vcf` vCard, rather than `.ged` GEDCOM. vCard isn’t concerned about re-assembling Families. So familial associations makes sense there.

---

<div class="post-metadata">

**Author:** ![comeng](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@comeng](https://gramps.discourse.group/u/comeng)\
**Post date:** [June 26, 2026, 1:46pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/8 "2026-06-26T13:46:31Z")

</div>

Thanks for that clarification don’t use vcard so will ignore  
phil

---

<div class="post-metadata">

**Author:** ![GeorgeWilmes](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@GeorgeWilmes](https://gramps.discourse.group/u/GeorgeWilmes)\
**Post date:** [June 26, 2026, 3:08pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/9 "2026-06-26T15:08:39Z")

</div>

> [@romjerome](#):
>
> there is not a clear direction on the documentation

Actually, there is an example in the link that you provided:

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/b/b94713b05964b1543fa607988f55e211ca771783.png)

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 3:29pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/10 "2026-06-26T15:29:26Z")

</div>

My bad, by “no direction”, I thought something like should be read “A is the {value} of B” or “A is the {mirror\_value} of B”. The association teacher/student or godparent/godchild does not modify the relation itself, just need to know where should we set the information or to know the ‘direction/orientation’ of the association.

About setting uncle or aunt as an association, this is maybe one alternate way to register one relation if we do not know yet who are the parents. e.g., one nephew, witness into his uncle’s event, or an uncle on any nephew’s event. We have an association but no families clearly set, like two individuals associations.

As pointed out by @PLegoux there is maybe an issue on the deep connexion code? It seems to try to guess a “reverse” association via the relationship built-in module, but maybe set the wrong starting person or return the wrong value on this type of relationship (uncle/nephew).

I did not look at the code, [..]

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 3:40pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/11 "2026-06-26T15:40:17Z")

</div>

> [@PLegoux](#):
>
> Is there a bug somewhere in the Deep Connexion gramplet?

Have you tried reversing something in the code (to see the difference)? For example, line 276 and after:

```diff
 for assoc in assoc_list:
            relation = _("%s (association)") % assoc.get_relation()
            assoc_handle = assoc.get_reference_handle()
- retval += [(assoc_handle, (path, (relation, person_handle)))]
+ retval += [(person_handle, (path, (relation, assoc_handle)))]

        retval += self.get_links_from_notes(
            person, path, _("Note on Person"), person_handle
        )

```

> <https://github.com/gramps-project/addons-source/blob/f09506c377d7f74dae4bdebf393425d575594220/DeepConnectionsGramplet/DeepConnectionsGramplet.py#L276>

> [@PLegoux](#):
>
> The “Check Associations Data” tool states that Jumel Guillaume is Ysel Michel’s uncle (which is the case), whereas the Deep Connexion Gramplet claims he is his nephew!

An improved version of the “Check Associations Data” tool should allow you to fix any errors (either in data entry or in the “orientation/direction” of the relation). It is now available on the 6.0 branch.

For the Deep Connexion gramplet, perhaps @emyoulation’s test case database does not exactly match your dataset?

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 4:00pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/12 "2026-06-26T16:00:24Z")

</div>

Yes, the relationship descriptor is still confusing for me. Why should we **only set** a great grandchild and not a second association record for the great grandparent? The choice is not clear. One specific rule or orientation during seizure? We cannot be consistent by filling the same logic (way or direction) during many years with a free form value as relation set. So, if we get the information that A is the great grandson of B and on an other one, we learn that B is the great grandfather of A, this might be that we are living into a perfect world. I am still waiting of such case into my genealogical tree!

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [June 26, 2026, 4:08pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/13 "2026-06-26T16:08:35Z")

</div>

Check out [Addon:SyncAssociation - Gramps](https://gramps-project.org/wiki/index.php/Addon:SyncAssociation)

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 4:21pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/14 "2026-06-26T16:21:38Z")

</div>

> The “Check Associations Data” tool states that Jumel Guillaume is Ysel Michel’s uncle[oncle] (which is the case),

I generated this tool for having a list of values for our associations records. It only displays a quick comparison tab. We get the association record via serialization! So, the textual value should be correct for the person set.

```python
  for ref in person.serialize()[-1]:

```

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [June 26, 2026, 5:38pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/15 "2026-06-26T17:38:05Z")

</div>

> [@PLegoux](#):
>
> The “Check Associations Data” tool states that Jumel Guillaume is Ysel Michel’s uncle[oncle] (which is the case), whereas Deep Connection Gramplet claims he is his nephew[neveu]!
> 
> A bug somewhere in the Deep Connection gramplet?

@PLegoux I did an experiment and the problems appears to be a confusing layout in the **Check Associations** table.

I set both Associations to have the corresponding Association to the other person.  
So, the Jumel Guillaume Association would be “Uncle” in the Ysel Michel profile, and the Ysel Michel Association would be “Nephew” in the Jumel Guillaume profile.

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/6/66d01a244db6f4fa05b6ac0bed66e1f9e370b2d5.png) ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/c/c50a6d16bc5aa2f24b79640835e1160d6b3bd2b6.png)  
The **Tools : Utilities : [Check Associations data…](https://www.gramps-project.org/wiki/index.php/Addon:Check_Associations)** Appears to have a layout bug.  
 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/b/b1175e2f861e4c4af0c296f0a4a6d912523af5c5.png)  
The columns are simply out of order for reading in the calculation. The exact same data swapping columns 2 and 4 (with the same header and same value in those columns) reads less ambiguously.  
 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/7/74882c896618b77ab3600ea6d38586b5c7fd43d4.png)

Deep Connections:

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/f/f6b1d3be70579c4e2fc0b2b5ab0f2a5e437e69a1.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/e/ef463d55935b0521df9bcc1fd7118a0ed89aa66a.png)

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/b/b45cd409bcab03fe0801d6bdecb34f7a4b6efc21.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/0/0f7c385735f46556f1a32a2981e38ab38871c79d.png)

[PLegoux.gramps](https://gramps.discourse.group/uploads/short-url/FULJ1RJBVEkr2FmKvpW32vOWHy.gramps) (2.8 KB)

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 9:23pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/16 "2026-06-26T21:23:15Z")

</div>

> [@emyoulation](#):
>
> The **Tools : Utilities : [Check Associations data…](https://www.gramps-project.org/wiki/index.php/Addon:Check_Associations)** Appears to have a layout bug.

Not certain that it is a layout bug as it is the expected data! I also wondering why @PLegoux cuts the relationship calculation column on this display (screenshot)…

[![](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/a/a654cae335b41dcd0f88dbc84059f3a10d5fda97.png) ](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/a/a654cae335b41dcd0f88dbc84059f3a10d5fda97.png)

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 9:28pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/17 "2026-06-26T21:28:17Z")

</div>

Note, this might be also a specific issue on the relationships handler for the French locale…

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 26, 2026, 9:35pm UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/18 "2026-06-26T21:35:46Z")

</div>

The relationship calculation as a secondary control (column) is not the most important data on the user side for this addon tool. The primary goal was to retrieve pure associations records from user data, as displayed on editors. The feeling of a layout bug might be this secondary test control (column) via the built-in localized relationships handler?

Sure, could be confusing as mixing two different data set or methods. One has been filled by the user and the second one is a simple calculation (or the machine one).

Maybe I also did a mistake on the primary or starting person for the relation. So, there is maybe at least two issues!

Note, there is now a quicker way to **check** these associations…

```python
for person in people():
    for ref in person.references:
        row(person, ref.rel, ref.reference)

```

> [@New Gram.py Script for 6.0](https://gramps.discourse.group/t/new-gram-py-script-for-6-0/7192/11):
>
> You get my point… wink[https://gramps.discourse.group/t/could-you-add-a-context-menu-to-the-association-state-tool-to-open-object-editors/5351](https://gramps.discourse.group/t/could-you-add-a-context-menu-to-the-association-state-tool-to-open-object-editors/5351)

---

<div class="post-metadata">

**Author:** ![GeorgeWilmes](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@GeorgeWilmes](https://gramps.discourse.group/u/GeorgeWilmes)\
**Post date:** [June 27, 2026, 12:51am UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/19 "2026-06-27T00:51:48Z")

</div>

> [@emyoulation](#):
>
> The columns are simply out of order for reading in the calculation. The exact same data swapping columns 2 and 4 (with the same header and same value in those columns) reads less ambiguously.

That works if the relationship can be traced. But I also enter associations to show relationships that are documented but not specific enough to allow me to connect the people through families. For example, an obituary lists children and grandchildren separately, and I can’t tell which grandchildren belong to which children. I add the grandchildren (not connected to any parents) and use associations to connect them to their deceased grandparent.

I patched my version of the tool by changing the column heading “Of” to “Linked Person”.

---

<div class="post-metadata">

**Author:** ![romjerome](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/romjerome/32/1489_2.png) [@romjerome](https://gramps.discourse.group/u/romjerome)\
**Post date:** [June 27, 2026, 10:10am UTC](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662/20 "2026-06-27T10:10:32Z")

</div>

> [@emyoulation](#):
>
> Is the Association a “To” or “From” relationship?

In fact, once the list of Associations has been generated, an other tool kept the same logic, with a simple statistic list, but only around calculated relations.

Takes it as an experimental spider, or global relationships interface and map. To also include associations data was not safe (“unfixed” seizures via free form) and a code review has been done recently, adding some additional columns or fixing some performances issues. The addon, named [**Relationships ID**](https://www.gramps-project.org/wiki/index.php/Addon:Display_relations_and_distances_with_the_home_person), related to the mapping stuff, has also a possible design issue, as it might be more “direct”. Something in “real time”, like the metadata stuff around given names statistics and active DB. Or maybe by also using power features like internal urls (e.g., from Note object or on gramplets) : something like a navigation feature and internal mapping.

To include a quick Matplotlib graph was also possible for (yet) an other alternate visualization of our relations without using reports API. Anyway, as we can export the new data set with these ‘raw’ groups of numbers, this can be done outside gramps. Do not worry, it does not generate a power matrix as I had to stop the AI during last reviews…

> <https://github.com/gramps-project/addons-source/pull/769#issuecomment-3286353529>
>
> I did not include some extra extensions like : (\_sorry, in french\_)
> \*\*Densité d…u réseau familial\*\*
> \*\*\_Mesure la densité des liens familiaux dans un sous-arbre (ex: nombre de mariages ou de liens par individu).\_\*\*
> \`\`\`@staticmethod
> def calculate\_family\_network\_density(db, person, generations=3):
> """
> Calcule la densité du réseau familial pour un individu sur un nombre donné de générations.
> La densité est définie comme le ratio entre le nombre de liens et le nombre d'individus.
> 
> Args:
> db: Base de données Gramps.
> person: Personne de référence.
> generations: Nombre de générations à considérer.
> 
> Returns:
> float: Densité du réseau (entre 0 et 1).
> """
> # Collecter tous les individus dans les générations spécifiées
> individuals = set()
> stack = \[(person, 0)\]
> 
> while stack:
> current\_person, generation = stack.pop()
> if generation \> generations:
> continue
> individuals.add(current\_person.get\_handle())
> 
> # Ajouter les parents
> for family\_handle in current\_person.get\_parent\_family\_handle\_list():
> family = db.get\_family\_from\_handle(family\_handle)
> for parent\_ref in \[family.get\_father\_handle(), family.get\_mother\_handle()\]:
> if parent\_ref:
> parent = db.get\_person\_from\_handle(parent\_ref)
> stack.append((parent, generation + 1))
> 
> # Ajouter les enfants
> for family\_handle in current\_person.get\_family\_handle\_list():
> family = db.get\_family\_from\_handle(family\_handle)
> for child\_ref in family.get\_child\_ref\_list():
> child = db.get\_person\_from\_handle(child\_ref.get\_reference\_handle())
> stack.append((child, generation + 1))
> 
> # Compter les liens (mariages et parent-enfant)
> num\_links = 0
> for individual\_handle in individuals:
> individual = db.get\_person\_from\_handle(individual\_handle)
> num\_links += len(individual.get\_family\_handle\_list()) # Mariages
> for family\_handle in individual.get\_parent\_family\_handle\_list():
> family = db.get\_family\_from\_handle(family\_handle)
> num\_links += len(family.get\_child\_ref\_list()) # Liens parent-enfant
> 
> num\_individuals = len(individuals)
> if num\_individuals \<= 1:
> return 0.0
> 
> # La densité est le ratio entre le nombre de liens et le nombre maximal possible de liens
> max\_possible\_links = num\_individuals \* (num\_individuals - 1) / 2
> return num\_links / max\_possible\_links
> \`\`\`
> or \*\*Détection des communautés familiales\*\*
> \*\*\_Identifie les sous-groupes (ou "communautés") fortement connectés dans un arbre généalogique (ex: familles élargies, branches distinctes).\_\*\*
> \`\`\`@staticmethod
> def detect\_family\_communities(db, person, generations=4):
> """
> Détecte les communautés familiales dans un sous-arbre en utilisant un algorithme simple de clustering.
> Retourne une liste de sous-ensembles d'individus fortement connectés.
> 
> Args:
> db: Base de données Gramps.
> person: Personne de référence.
> generations: Nombre de générations à considérer.
> 
> Returns:
> list: Liste de sets, où chaque set représente une communauté.
> """
> from collections import defaultdict
> 
> # Collecter tous les individus et leurs liens
> individuals = set()
> links = defaultdict(set)
> stack = \[(person, 0)\]
> 
> while stack:
> current\_person, generation = stack.pop()
> if generation \> generations:
> continue
> current\_handle = current\_person.get\_handle()
> individuals.add(current\_handle)
> 
> # Ajouter les liens avec les parents
> for family\_handle in current\_person.get\_parent\_family\_handle\_list():
> family = db.get\_family\_from\_handle(family\_handle)
> for parent\_ref in \[family.get\_father\_handle(), family.get\_mother\_handle()\]:
> if parent\_ref:
> parent = db.get\_person\_from\_handle(parent\_ref)
> parent\_handle = parent.get\_handle()
> individuals.add(parent\_handle)
> links\[current\_handle\].add(parent\_handle)
> links\[parent\_handle\].add(current\_handle)
> stack.append((parent, generation + 1))
> 
> # Ajouter les liens avec les enfants et conjoints
> for family\_handle in current\_person.get\_family\_handle\_list():
> family = db.get\_family\_from\_handle(family\_handle)
> # Conjoints
> for spouse\_ref in \[family.get\_father\_handle(), family.get\_mother\_handle()\]:
> if spouse\_ref and spouse\_ref != current\_handle:
> spouse = db.get\_person\_from\_handle(spouse\_ref)
> spouse\_handle = spouse.get\_handle()
> individuals.add(spouse\_handle)
> links\[current\_handle\].add(spouse\_handle)
> links\[spouse\_handle\].add(current\_handle)
> # Enfants
> for child\_ref in family.get\_child\_ref\_list():
> child = db.get\_person\_from\_handle(child\_ref.get\_reference\_handle())
> child\_handle = child.get\_handle()
> individuals.add(child\_handle)
> links\[current\_handle\].add(child\_handle)
> links\[child\_handle\].add(current\_handle)
> stack.append((child, generation + 1))
> 
> # Algorithme simple de clustering (ex: composantes connexes)
> visited = set()
> communities = \[\]
> 
> for individual in individuals:
> if individual not in visited:
> stack = \[individual\]
> community = set()
> while stack:
> node = stack.pop()
> if node not in visited:
> visited.add(node)
> community.add(node)
> for neighbor in links\[node\]:
> if neighbor not in visited:
> stack.append(neighbor)
> communities.append(community)
> 
> return communities
> \`\`\`
> it was too far (multiple prompts for debug) and maybe it increases too much the number of columns.
> 
> Here some lines (documentation) for helping to use these additionnal data or where to go with such improvements:
> 
> \* In-depth analysis: Allows for understanding the structure and dynamics of families.
> \* Visualization: Can be used to generate family network graphs (e.g., with NetworkX or Gephi).
> \* Pattern detection: Identifies extended families, isolated branches, or central individuals.
> \* Customization: Adaptable to specific needs (e.g., research on consanguinity, migrations, etc.).

_I guess that Claude will also go very far by looking at the current code_.

[Next page](https://gramps.discourse.group/t/associations-who-is-telling-the-truth/9662.md?page=2)
