Assignment 2
Assignment 2
1. Imagine you want to connect with a famous AI researcher, Dr. Meera, on LinkedIn.
You don’t know her personally, but you have mutual connections. You want to find the
best way to get an introduction.
However, not all connections are equal! Some people know each other well (strong
connection), while others are just casual acquaintances (weak connection). If you go
through the strongest connections, you have a higher chance of getting a meaningful
introduction. How would you increase your chances to get best introduction.
2. Now, imagine that not all your connections help you equally. Some people have a
positive reputation (boosting your chances of a good introduction), while others have a
negative reputation (hurting your credibility).
Your goal is still to reach Dr. Meera, but this time, you want to take a path where the
overall influence score (sum of weights) is as high as possible (or least negative). How
would you increase your chances to get best introduction?
SOLUTION :-
#include <stdio.h>
#include <limits.h>
int i;
for (i = 0; i < nodes; i++) {
dist[i] = INF;
}
dist[src] = 0;
int count;
int v;
for (v = 0; v < nodes; v++) {
if (!visited[v] && graph[u][v] && dist[u] != INF && dist[u] + graph[u][v]
< dist[v]) {
dist[v] = dist[u] + graph[u][v];
}
}
}
int main() {
int nodes, edges, u, v, weight, src;
int graph[MAX_NODES][MAX_NODES] = {0};