-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from fhstp/clique_analysis
Clique analysis
- Loading branch information
Showing
7 changed files
with
271 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<template> | ||
<div class="panel-block" style="display: block"> | ||
<table class="table is-fullwidth"> | ||
<tbody> | ||
<tr> | ||
<th title="Clique">{{ t("amountClique") }}</th> | ||
<td>{{ cliquesList.length }}</td> | ||
</tr> | ||
<tr | ||
v-for="(clique, cliqueIndex) in cliquesList" | ||
:key="'clique-number-' + cliqueIndex" | ||
> | ||
<th @click="clickClique(clique.alters)" class="clickAble"> | ||
<template | ||
v-for="(a, idx) in clique.alters" | ||
:key="`a_${cliqueIndex}_${idx}`" | ||
> | ||
<template v-if="idx > 0">, </template> | ||
<span :class="{ selalter: isSelected(a.id) }">{{ a.name }}</span> | ||
</template> | ||
</th> | ||
<td> | ||
{{ clique.description }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed, defineComponent } from "vue"; | ||
import { useStore } from "@/store"; | ||
import { findCliques } from "@/data/NetworkClustering"; | ||
import { sectorIndex } from "@/data/AlterCategories"; | ||
import de from "@/de"; | ||
import en from "@/en"; | ||
import { Alter } from "@/data/Alter"; | ||
import { Sectors, SectorsEng } from "@/data/Sectors"; | ||
interface CliqueItem { | ||
alters: Alter[]; | ||
description: string; | ||
} | ||
export default defineComponent({ | ||
mixins: [de, en], | ||
methods: { | ||
t(prop: string) { | ||
return this[document.documentElement.lang][prop]; | ||
}, | ||
}, | ||
setup() { | ||
const store = useStore(); | ||
const sectorLabels = | ||
document.documentElement.lang === "de" ? Sectors : SectorsEng; | ||
const cliques = computed((): Alter[][] => { | ||
return findCliques(store.state.nwk); | ||
}); | ||
const cliquesList = computed((): CliqueItem[] => { | ||
return cliques.value.map((clique) => { | ||
const sectorIndices = clique | ||
.map((a) => sectorIndex(a)) | ||
.filter((d) => d !== null); | ||
const uniqSectorIndices = [...new Set(sectorIndices)]; | ||
console.log(uniqSectorIndices); | ||
const sectLabels = uniqSectorIndices | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
.map((d) => sectorLabels[d!]) | ||
.join(", "); | ||
return { | ||
// cliqueNumber: `Clique ${idx + 1}`, | ||
alters: clique, | ||
description: clique.length + " (" + sectLabels + ")", | ||
}; | ||
}); | ||
}); | ||
const clickClique = (alteri: Alter[]) => { | ||
if (alteri.length > 0) { | ||
store.commit( | ||
"session/selectAlters", | ||
alteri.map((a) => a.id) | ||
); | ||
} | ||
}; | ||
return { | ||
cliquesList, | ||
clickClique, | ||
isSelected: store.getters["session/isSelected"], | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
span.selalter { | ||
color: rgb(30, 92, 146); | ||
font-weight: bold; | ||
} | ||
thead th:not([align]) { | ||
text-align: right; | ||
} | ||
td:not([align]) { | ||
text-align: right; | ||
} | ||
th { | ||
font-weight: normal; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.