In this paper, wireless sensor network (WSN) topology optimization for dependability is considered, where two metrics "reliability" and "integrity" for WSN are defined. First, static topology optimization problem for reliability, integrity and joint optimization of them are investigated and some trade-off relationships are clarified. Then, dynamic topology optimization problem is proposed, where some node connections to their parents' nodes change dynamically with a stochastic distribution rate. Then a heuristic optimization method and some functions for each node to realize a decentralized optimization are proposed. Finally some numerical examples are illustrated to demonstrate the effectiveness of these optimization methods and the optimal WSN topology in various optimization problems.