Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Degree filter on large query #416

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/components/ConnectivityQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,38 @@ export default defineComponent({

// Update state with new network
store.dispatch.aggregateNetwork(undefined);
store.dispatch.updateNetwork({ network: newNetwork });
store.commit.setNetworkPreFilter(newNetwork);
loading.value = false;
store.commit.setDirectionalEdges(true);
store.commit.setQueriedNetworkState(true);
store.commit.setDegreeEntries(setNodeDegreeDict(store.state.networkPreFilter, store.state.networkOnLoad, store.state.queriedNetwork, store.state.directionalEdges));
if (promise.length >= 100) {
// Create dictionary of degree occurences
const orderedList = Object.values(store.state.nodeDegreeDict).sort((a, b) => a - b);
const degreeCount: {[key:number]:number} = {};
orderedList.forEach((olItem) => {
degreeCount[olItem] = (degreeCount[olItem] || 0) + 1;
});

// Set min value if the node degree occurrence < 100
// Using every to stop for loop once the conditional is met
if (
// If all degrees have 100 connections of more
Object.entries(degreeCount).every(([degree, occurrence]) => {
if (occurrence < 100) {
store.commit.setMinDegree(Number(degree));
// This calls updateNetwork
store.commit.setDegreeNetwork([Number(degree), store.state.maxDegree]);
return false;
} return true;
})
) {
store.dispatch.updateNetwork({ network: newNetwork });
}
} else {
// Update state with new network
store.dispatch.updateNetwork({ network: newNetwork });
}
} else {
// Update state with empty network
store.dispatch.aggregateNetwork(undefined);
Expand Down
7 changes: 4 additions & 3 deletions src/components/ControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ export default defineComponent({
});
const maxConnections = computed(() => store.state.maxConnections);
const maxDegree = computed(() => store.state.maxDegree);
const degreeRange = ref([0, maxDegree.value]);
const minDegree = computed(() => store.state.minDegree);
const degreeRange = ref([minDegree.value, maxDegree.value]);

watch([maxDegree], () => {
degreeRange.value = [0, maxDegree.value];
watch([maxDegree, minDegree], () => {
degreeRange.value = [minDegree.value, maxDegree.value];
});

// Intermediate node table template objects
Expand Down
6 changes: 5 additions & 1 deletion src/components/MultiMatrix.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ export default defineComponent({
// Loop through other props to add to tooltip
Object.keys(networkElement).forEach((key) => {
if (!['_key', '_rev', 'id', 'neighbors'].includes(key)) {
message += `<br/> ${capitalizeFirstLetter(key)}: ${networkElement[key]}`;
if (key === 'children' && networkElement.children !== undefined) {
message += `<br/> ${capitalizeFirstLetter(key)}: ${networkElement.children.length}`;
} else {
message += `<br/> ${capitalizeFirstLetter(key)}: ${networkElement[key]}`;
}
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const {
selectedHops: 1,
nodeDegreeDict: {},
maxDegree: 0,
minDegree: 0,
networkPreFilter: null,
queriedNetwork: false,
filteredNetwork: false,
Expand Down Expand Up @@ -389,6 +390,10 @@ const {
state.nodeDegreeDict = degreeObject.nodeDegreeDict;
},

setMinDegree(state, minDegree: number) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a setMaxDegree, why can't we just get this info from setDegreeNetwork or another setDegreeEntries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep it separate because in ControlPanel.vue minDegree is a computed value and it should be 0 unless it is a large query

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We met to discuss this. There are likely some edge cases that this will break

state.minDegree = minDegree;
},

setDegreeNetwork(state, degreeRange: number[]) {
// Determine correct network to use
let baseNetwork: Network = { nodes: [], edges: [] };
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface State {
selectedHops: number;
nodeDegreeDict: { [key: string]: number };
maxDegree: number;
minDegree: number;
networkPreFilter: Network | null;
queriedNetwork: boolean;
filteredNetwork: boolean;
Expand Down