Just a runnable solution
Code\n\nimpl Solution {\n    pub fn count_subgraphs_for_each_diameter(n: i32, edges: Vec<Vec<i32>>) -> Vec<i32> {\n        let mut g = vec![vec![999; n as usize
# Code\n```\nimpl Solution {\n    pub fn count_subgraphs_for_each_diameter(n: i32, edges: Vec<Vec<i32>>) -> Vec<i32> {\n        let mut g = vec![vec![999; n as usize]; n as usize];\n        for e in edges.iter() {\n            let i = (e[0] - 1) as usize;\n            let j = (e[1] - 1) as usize;\n            g[i][j] = 1;\n            g[j][i] = 1;\n        }\n        for k in 0..n as usize {\n            for i in 0..n as usize {\n                for j in 0..n as usize {\n                    g[i][j] = g[i][j].min(g[i][k] + g[k][j]);\n                }\n            }\n        }\n        let mut ans = vec![0; n as usize - 1];\n        for s in 0_i32..(1 << n) {\n            let k = s.count_ones() as i32;\n            let (mut e, mut d) = (0_i32, 0_i32);\n            for (i, item) in g.iter().enumerate().take(n as usize) {\n                if s & (1 << i) != 0 {\n                    for (j, &item_j) in item.iter().enumerate().take(n as usize).skip(i + 1) {\n                        if s & (1 << j) != 0 {\n                            e += i32::from(g[i][j] == 1);\n                            d = d.max(item_j);\n                        }\n                    }\n                }\n            }\n            if e == k - 1 && d > 0 {\n                ans[(d - 1) as usize] += 1;\n            }\n        }\n\n        ans\n    }\n}\n```
['Rust']